package kotlin.reflect.w.internal;

import g.a.a.a.a;
import g.h.a.i;
import java.lang.reflect.GenericArrayType;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.util.List;
import kotlin.Lazy;
import kotlin.Metadata;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Lambda;
import kotlin.jvm.internal.o;

/* JADX INFO: loaded from: classes.dex */
@Metadata(d1 = {"\u0000\b\n\u0000\n\u0002\u0018\u0002\n\u0000\u0010\u0000\u001a\u00020\u0001H\n¢\u0006\u0002\b\u0002"}, d2 = {"<no name provided>", "Ljava/lang/reflect/Type;", "invoke"}, k = 3, mv = {1, 7, 1}, xi = 48)
public final class g0 extends Lambda implements Function0<Type> {

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public final /* synthetic */ KTypeImpl f6300f;

    /* JADX INFO: renamed from: m, reason: collision with root package name */
    public final /* synthetic */ int f6301m;

    /* JADX INFO: renamed from: n, reason: collision with root package name */
    public final /* synthetic */ Lazy<List<Type>> f6302n;

    /* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
    /* JADX WARN: Multi-variable type inference failed */
    public g0(KTypeImpl kTypeImpl, int i2, Lazy<? extends List<? extends Type>> lazy) {
        super(0);
        this.f6300f = kTypeImpl;
        this.f6301m = i2;
        this.f6302n = lazy;
    }

    @Override // kotlin.jvm.functions.Function0
    public Type invoke() {
        Class genericComponentType;
        Type typeI = this.f6300f.i();
        if (typeI instanceof Class) {
            Class cls = (Class) typeI;
            genericComponentType = cls.isArray() ? cls.getComponentType() : Object.class;
        } else if (typeI instanceof GenericArrayType) {
            if (this.f6301m != 0) {
                StringBuilder sbF = a.F("Array type has been queried for a non-0th argument: ");
                sbF.append(this.f6300f);
                throw new KotlinReflectionInternalError(sbF.toString());
            }
            genericComponentType = ((GenericArrayType) typeI).getGenericComponentType();
        } else {
            if (!(typeI instanceof ParameterizedType)) {
                StringBuilder sbF2 = a.F("Non-generic type has been queried for arguments: ");
                sbF2.append(this.f6300f);
                throw new KotlinReflectionInternalError(sbF2.toString());
            }
            genericComponentType = this.f6302n.getValue().get(this.f6301m);
            if (genericComponentType instanceof WildcardType) {
                WildcardType wildcardType = (WildcardType) genericComponentType;
                Type[] lowerBounds = wildcardType.getLowerBounds();
                o.e(lowerBounds, "argument.lowerBounds");
                Type type = (Type) i.P0(lowerBounds);
                if (type == null) {
                    Type[] upperBounds = wildcardType.getUpperBounds();
                    o.e(upperBounds, "argument.upperBounds");
                    genericComponentType = (Type) i.O0(upperBounds);
                } else {
                    genericComponentType = type;
                }
            }
        }
        o.e(genericComponentType, "{\n                      …                        }");
        return genericComponentType;
    }
}
