167 lines
9.9 KiB
Java
167 lines
9.9 KiB
Java
package kotlin.reflect.full;
|
|
|
|
import java.lang.annotation.Annotation;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import kotlin.Metadata;
|
|
import kotlin.NoWhenBranchMatchedException;
|
|
import kotlin.SinceKotlin;
|
|
import kotlin.collections.CollectionsKt;
|
|
import kotlin.collections.CollectionsKt__IterablesKt;
|
|
import kotlin.jvm.JvmName;
|
|
import kotlin.jvm.internal.Intrinsics;
|
|
import kotlin.jvm.internal.SourceDebugExtension;
|
|
import kotlin.reflect.KClassifier;
|
|
import kotlin.reflect.KType;
|
|
import kotlin.reflect.KTypeProjection;
|
|
import kotlin.reflect.KVariance;
|
|
import kotlin.reflect.jvm.internal.KClassifierImpl;
|
|
import kotlin.reflect.jvm.internal.KTypeImpl;
|
|
import kotlin.reflect.jvm.internal.KotlinReflectionInternalError;
|
|
import kotlin.reflect.jvm.internal.impl.descriptors.ClassifierDescriptor;
|
|
import kotlin.reflect.jvm.internal.impl.descriptors.TypeParameterDescriptor;
|
|
import kotlin.reflect.jvm.internal.impl.types.KotlinType;
|
|
import kotlin.reflect.jvm.internal.impl.types.KotlinTypeFactory;
|
|
import kotlin.reflect.jvm.internal.impl.types.SimpleType;
|
|
import kotlin.reflect.jvm.internal.impl.types.StarProjectionImpl;
|
|
import kotlin.reflect.jvm.internal.impl.types.TypeAttributes;
|
|
import kotlin.reflect.jvm.internal.impl.types.TypeConstructor;
|
|
import kotlin.reflect.jvm.internal.impl.types.TypeProjectionBase;
|
|
import kotlin.reflect.jvm.internal.impl.types.TypeProjectionImpl;
|
|
import kotlin.reflect.jvm.internal.impl.types.Variance;
|
|
import kotlin.reflect.jvm.internal.impl.types.checker.KotlinTypeRefiner;
|
|
|
|
@Metadata(d1 = {"\u00008\n\u0000\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010 \n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\u001b\n\u0000\u001a.\u0010\u0007\u001a\u00020\b2\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\f2\f\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u000f0\u000e2\u0006\u0010\u0010\u001a\u00020\u0011H\u0002\u001a6\u0010\u0012\u001a\u00020\u0001*\u00020\u00022\u000e\b\u0002\u0010\r\u001a\b\u0012\u0004\u0012\u00020\u000f0\u000e2\b\b\u0002\u0010\u0010\u001a\u00020\u00112\u000e\b\u0002\u0010\u0013\u001a\b\u0012\u0004\u0012\u00020\u00140\u000eH\u0007\"\u001e\u0010\u0000\u001a\u00020\u0001*\u00020\u00028FX\u0087\u0004¢\u0006\f\u0012\u0004\b\u0003\u0010\u0004\u001a\u0004\b\u0005\u0010\u0006¨\u0006\u0015"}, d2 = {"starProjectedType", "Lkotlin/reflect/KType;", "Lkotlin/reflect/KClassifier;", "getStarProjectedType$annotations", "(Lkotlin/reflect/KClassifier;)V", "getStarProjectedType", "(Lkotlin/reflect/KClassifier;)Lkotlin/reflect/KType;", "createKotlinType", "Lkotlin/reflect/jvm/internal/impl/types/SimpleType;", "attributes", "Lkotlin/reflect/jvm/internal/impl/types/TypeAttributes;", "typeConstructor", "Lkotlin/reflect/jvm/internal/impl/types/TypeConstructor;", "arguments", "", "Lkotlin/reflect/KTypeProjection;", "nullable", "", "createType", "annotations", "", "kotlin-reflection"}, k = 2, mv = {1, 9, 0}, xi = 48)
|
|
@JvmName(name = "KClassifiers")
|
|
@SourceDebugExtension({"SMAP\nKClassifiers.kt\nKotlin\n*S Kotlin\n*F\n+ 1 KClassifiers.kt\nkotlin/reflect/full/KClassifiers\n+ 2 _Collections.kt\nkotlin/collections/CollectionsKt___CollectionsKt\n*L\n1#1,97:1\n1559#2:98\n1590#2,4:99\n1549#2:103\n1620#2,3:104\n*S KotlinDebug\n*F\n+ 1 KClassifiers.kt\nkotlin/reflect/full/KClassifiers\n*L\n69#1:98\n69#1:99,4\n95#1:103\n95#1:104,3\n*E\n"})
|
|
/* loaded from: classes3.dex */
|
|
public final class KClassifiers {
|
|
|
|
@Metadata(k = 3, mv = {1, 9, 0}, xi = 48)
|
|
/* loaded from: classes3.dex */
|
|
public /* synthetic */ class WhenMappings {
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
static {
|
|
int[] iArr = new int[KVariance.values().length];
|
|
try {
|
|
iArr[KVariance.INVARIANT.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
iArr[KVariance.IN.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
iArr[KVariance.OUT.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
$EnumSwitchMapping$0 = iArr;
|
|
}
|
|
}
|
|
|
|
private static final SimpleType createKotlinType(TypeAttributes typeAttributes, TypeConstructor typeConstructor, List<KTypeProjection> list, boolean z3) {
|
|
int collectionSizeOrDefault;
|
|
TypeProjectionBase starProjectionImpl;
|
|
List<TypeParameterDescriptor> parameters = typeConstructor.getParameters();
|
|
Intrinsics.checkNotNullExpressionValue(parameters, "getParameters(...)");
|
|
List<KTypeProjection> list2 = list;
|
|
collectionSizeOrDefault = CollectionsKt__IterablesKt.collectionSizeOrDefault(list2, 10);
|
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
|
|
int i = 0;
|
|
for (Object obj : list2) {
|
|
int i4 = i + 1;
|
|
if (i < 0) {
|
|
CollectionsKt.throwIndexOverflow();
|
|
}
|
|
KTypeProjection kTypeProjection = (KTypeProjection) obj;
|
|
KTypeImpl kTypeImpl = (KTypeImpl) kTypeProjection.getType();
|
|
KotlinType type = kTypeImpl != null ? kTypeImpl.getType() : null;
|
|
KVariance variance = kTypeProjection.getVariance();
|
|
int i5 = variance == null ? -1 : WhenMappings.$EnumSwitchMapping$0[variance.ordinal()];
|
|
if (i5 == -1) {
|
|
TypeParameterDescriptor typeParameterDescriptor = parameters.get(i);
|
|
Intrinsics.checkNotNullExpressionValue(typeParameterDescriptor, "get(...)");
|
|
starProjectionImpl = new StarProjectionImpl(typeParameterDescriptor);
|
|
} else if (i5 == 1) {
|
|
Variance variance2 = Variance.INVARIANT;
|
|
Intrinsics.checkNotNull(type);
|
|
starProjectionImpl = new TypeProjectionImpl(variance2, type);
|
|
} else if (i5 == 2) {
|
|
Variance variance3 = Variance.IN_VARIANCE;
|
|
Intrinsics.checkNotNull(type);
|
|
starProjectionImpl = new TypeProjectionImpl(variance3, type);
|
|
} else {
|
|
if (i5 != 3) {
|
|
throw new NoWhenBranchMatchedException();
|
|
}
|
|
Variance variance4 = Variance.OUT_VARIANCE;
|
|
Intrinsics.checkNotNull(type);
|
|
starProjectionImpl = new TypeProjectionImpl(variance4, type);
|
|
}
|
|
arrayList.add(starProjectionImpl);
|
|
i = i4;
|
|
}
|
|
return KotlinTypeFactory.simpleType$default(typeAttributes, typeConstructor, arrayList, z3, (KotlinTypeRefiner) null, 16, (Object) null);
|
|
}
|
|
|
|
@SinceKotlin(version = "1.1")
|
|
public static final KType createType(KClassifier kClassifier, List<KTypeProjection> arguments, boolean z3, List<? extends Annotation> annotations) {
|
|
ClassifierDescriptor descriptor;
|
|
Intrinsics.checkNotNullParameter(kClassifier, "<this>");
|
|
Intrinsics.checkNotNullParameter(arguments, "arguments");
|
|
Intrinsics.checkNotNullParameter(annotations, "annotations");
|
|
KClassifierImpl kClassifierImpl = kClassifier instanceof KClassifierImpl ? (KClassifierImpl) kClassifier : null;
|
|
if (kClassifierImpl == null || (descriptor = kClassifierImpl.getDescriptor()) == null) {
|
|
throw new KotlinReflectionInternalError("Cannot create type for an unsupported classifier: " + kClassifier + " (" + kClassifier.getClass() + ')');
|
|
}
|
|
TypeConstructor typeConstructor = descriptor.getTypeConstructor();
|
|
Intrinsics.checkNotNullExpressionValue(typeConstructor, "getTypeConstructor(...)");
|
|
List<TypeParameterDescriptor> parameters = typeConstructor.getParameters();
|
|
Intrinsics.checkNotNullExpressionValue(parameters, "getParameters(...)");
|
|
if (parameters.size() == arguments.size()) {
|
|
return new KTypeImpl(createKotlinType(annotations.isEmpty() ? TypeAttributes.Companion.getEmpty() : TypeAttributes.Companion.getEmpty(), typeConstructor, arguments, z3), null, 2, null);
|
|
}
|
|
throw new IllegalArgumentException("Class declares " + parameters.size() + " type parameters, but " + arguments.size() + " were provided.");
|
|
}
|
|
|
|
public static /* synthetic */ KType createType$default(KClassifier kClassifier, List list, boolean z3, List list2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
list = CollectionsKt.emptyList();
|
|
}
|
|
if ((i & 2) != 0) {
|
|
z3 = false;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
list2 = CollectionsKt.emptyList();
|
|
}
|
|
return createType(kClassifier, list, z3, list2);
|
|
}
|
|
|
|
public static final KType getStarProjectedType(KClassifier kClassifier) {
|
|
ClassifierDescriptor descriptor;
|
|
int collectionSizeOrDefault;
|
|
Intrinsics.checkNotNullParameter(kClassifier, "<this>");
|
|
KClassifierImpl kClassifierImpl = kClassifier instanceof KClassifierImpl ? (KClassifierImpl) kClassifier : null;
|
|
if (kClassifierImpl == null || (descriptor = kClassifierImpl.getDescriptor()) == null) {
|
|
return createType$default(kClassifier, null, false, null, 7, null);
|
|
}
|
|
List<TypeParameterDescriptor> parameters = descriptor.getTypeConstructor().getParameters();
|
|
Intrinsics.checkNotNullExpressionValue(parameters, "getParameters(...)");
|
|
if (parameters.isEmpty()) {
|
|
return createType$default(kClassifier, null, false, null, 7, null);
|
|
}
|
|
List<TypeParameterDescriptor> list = parameters;
|
|
collectionSizeOrDefault = CollectionsKt__IterablesKt.collectionSizeOrDefault(list, 10);
|
|
ArrayList arrayList = new ArrayList(collectionSizeOrDefault);
|
|
for (TypeParameterDescriptor typeParameterDescriptor : list) {
|
|
arrayList.add(KTypeProjection.INSTANCE.getSTAR());
|
|
}
|
|
return createType$default(kClassifier, arrayList, false, null, 6, null);
|
|
}
|
|
|
|
@SinceKotlin(version = "1.1")
|
|
public static /* synthetic */ void getStarProjectedType$annotations(KClassifier kClassifier) {
|
|
}
|
|
}
|