package kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors;

import androidx.media3.extractor.text.ttml.TtmlNode;
import com.google.android.gms.measurement.api.AppMeasurementSdk;
import defpackage.cr4;
import defpackage.dw7;
import defpackage.fi7;
import defpackage.hk7;
import defpackage.hl4;
import defpackage.ik2;
import defpackage.il4;
import defpackage.iw7;
import defpackage.jk2;
import defpackage.jl4;
import defpackage.kp6;
import defpackage.kw7;
import defpackage.n41;
import defpackage.pq6;
import defpackage.q07;
import defpackage.qq3;
import defpackage.sq3;
import defpackage.uz1;
import defpackage.vx8;
import defpackage.wo5;
import defpackage.y41;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import kotlin.reflect.KProperty;
import kotlin.reflect.jvm.internal.impl.builtins.KotlinBuiltIns;
import kotlin.reflect.jvm.internal.impl.descriptors.CallableDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ClassDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.DeclarationDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.FunctionDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.Modality;
import kotlin.reflect.jvm.internal.impl.descriptors.PropertyDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ReceiverParameterDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.SimpleFunctionDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.TypeParameterDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.ValueParameterDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.VariableDescriptor;
import kotlin.reflect.jvm.internal.impl.descriptors.annotations.Annotations;
import kotlin.reflect.jvm.internal.impl.descriptors.impl.PropertyDescriptorImpl;
import kotlin.reflect.jvm.internal.impl.descriptors.impl.ValueParameterDescriptorImpl;
import kotlin.reflect.jvm.internal.impl.incremental.components.LookupLocation;
import kotlin.reflect.jvm.internal.impl.incremental.components.NoLookupLocation;
import kotlin.reflect.jvm.internal.impl.load.java.UtilsKt;
import kotlin.reflect.jvm.internal.impl.load.java.descriptors.JavaMethodDescriptor;
import kotlin.reflect.jvm.internal.impl.load.java.descriptors.JavaPropertyDescriptor;
import kotlin.reflect.jvm.internal.impl.load.java.lazy.ContextKt;
import kotlin.reflect.jvm.internal.impl.load.java.lazy.LazyJavaAnnotationsKt;
import kotlin.reflect.jvm.internal.impl.load.java.lazy.LazyJavaResolverContext;
import kotlin.reflect.jvm.internal.impl.load.java.lazy.types.JavaTypeAttributes;
import kotlin.reflect.jvm.internal.impl.load.java.lazy.types.JavaTypeAttributesKt;
import kotlin.reflect.jvm.internal.impl.load.java.structure.JavaArrayType;
import kotlin.reflect.jvm.internal.impl.load.java.structure.JavaField;
import kotlin.reflect.jvm.internal.impl.load.java.structure.JavaMethod;
import kotlin.reflect.jvm.internal.impl.load.java.structure.JavaType;
import kotlin.reflect.jvm.internal.impl.load.java.structure.JavaTypeParameter;
import kotlin.reflect.jvm.internal.impl.load.java.structure.JavaValueParameter;
import kotlin.reflect.jvm.internal.impl.load.kotlin.MethodSignatureMappingKt;
import kotlin.reflect.jvm.internal.impl.name.Name;
import kotlin.reflect.jvm.internal.impl.resolve.DescriptorFactory;
import kotlin.reflect.jvm.internal.impl.resolve.DescriptorUtils;
import kotlin.reflect.jvm.internal.impl.resolve.OverridingUtilsKt;
import kotlin.reflect.jvm.internal.impl.resolve.constants.ConstantValue;
import kotlin.reflect.jvm.internal.impl.resolve.scopes.DescriptorKindExclude;
import kotlin.reflect.jvm.internal.impl.resolve.scopes.DescriptorKindFilter;
import kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScope;
import kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl;
import kotlin.reflect.jvm.internal.impl.storage.MemoizedFunctionToNotNull;
import kotlin.reflect.jvm.internal.impl.storage.MemoizedFunctionToNullable;
import kotlin.reflect.jvm.internal.impl.storage.NotNullLazyValue;
import kotlin.reflect.jvm.internal.impl.storage.NullableLazyValue;
import kotlin.reflect.jvm.internal.impl.storage.StorageKt;
import kotlin.reflect.jvm.internal.impl.types.KotlinType;
import kotlin.reflect.jvm.internal.impl.types.TypeUsage;
import kotlin.reflect.jvm.internal.impl.types.TypeUtils;
import kotlin.reflect.jvm.internal.impl.utils.CollectionsKt;

/* JADX INFO: loaded from: classes3.dex */
@vx8
public abstract class LazyJavaScope extends MemberScopeImpl {
    static final /* synthetic */ KProperty<Object>[] $$delegatedProperties;

    @kp6
    private final NotNullLazyValue<Collection<DeclarationDescriptor>> allDescriptors;

    @kp6
    private final LazyJavaResolverContext c;

    @kp6
    private final NotNullLazyValue classNamesLazy$delegate;

    @kp6
    private final MemoizedFunctionToNullable<Name, PropertyDescriptor> declaredField;

    @kp6
    private final MemoizedFunctionToNotNull<Name, Collection<SimpleFunctionDescriptor>> declaredFunctions;

    @kp6
    private final NotNullLazyValue<DeclaredMemberIndex> declaredMemberIndex;

    @kp6
    private final NotNullLazyValue functionNamesLazy$delegate;

    @kp6
    private final MemoizedFunctionToNotNull<Name, Collection<SimpleFunctionDescriptor>> functions;

    @pq6
    private final LazyJavaScope mainScope;

    @kp6
    private final MemoizedFunctionToNotNull<Name, List<PropertyDescriptor>> properties;

    @kp6
    private final NotNullLazyValue propertyNamesLazy$delegate;

    public static final class MethodSignatureData {

        @kp6
        private final List<String> errors;
        private final boolean hasStableParameterNames;

        @pq6
        private final KotlinType receiverType;

        @kp6
        private final KotlinType returnType;

        @kp6
        private final List<TypeParameterDescriptor> typeParameters;

        @kp6
        private final List<ValueParameterDescriptor> valueParameters;

        /* JADX WARN: Multi-variable type inference failed */
        public MethodSignatureData(@kp6 KotlinType kotlinType, @pq6 KotlinType kotlinType2, @kp6 List<? extends ValueParameterDescriptor> list, @kp6 List<? extends TypeParameterDescriptor> list2, boolean z, @kp6 List<String> list3) {
            cr4.g(kotlinType, "returnType");
            cr4.g(list, "valueParameters");
            cr4.g(list2, "typeParameters");
            cr4.g(list3, "errors");
            this.returnType = kotlinType;
            this.receiverType = kotlinType2;
            this.valueParameters = list;
            this.typeParameters = list2;
            this.hasStableParameterNames = z;
            this.errors = list3;
        }

        public boolean equals(@pq6 Object obj) {
            if (this == obj) {
                return true;
            }
            if (!(obj instanceof MethodSignatureData)) {
                return false;
            }
            MethodSignatureData methodSignatureData = (MethodSignatureData) obj;
            return cr4.b(this.returnType, methodSignatureData.returnType) && cr4.b(this.receiverType, methodSignatureData.receiverType) && cr4.b(this.valueParameters, methodSignatureData.valueParameters) && cr4.b(this.typeParameters, methodSignatureData.typeParameters) && this.hasStableParameterNames == methodSignatureData.hasStableParameterNames && cr4.b(this.errors, methodSignatureData.errors);
        }

        @kp6
        public final List<String> getErrors() {
            return this.errors;
        }

        public final boolean getHasStableParameterNames() {
            return this.hasStableParameterNames;
        }

        @pq6
        public final KotlinType getReceiverType() {
            return this.receiverType;
        }

        @kp6
        public final KotlinType getReturnType() {
            return this.returnType;
        }

        @kp6
        public final List<TypeParameterDescriptor> getTypeParameters() {
            return this.typeParameters;
        }

        @kp6
        public final List<ValueParameterDescriptor> getValueParameters() {
            return this.valueParameters;
        }

        public int hashCode() {
            int iHashCode = this.returnType.hashCode() * 31;
            KotlinType kotlinType = this.receiverType;
            return this.errors.hashCode() + fi7.c(fi7.d(this.typeParameters, fi7.d(this.valueParameters, (iHashCode + (kotlinType == null ? 0 : kotlinType.hashCode())) * 31, 31), 31), 31, this.hasStableParameterNames);
        }

        @kp6
        public String toString() {
            return "MethodSignatureData(returnType=" + this.returnType + ", receiverType=" + this.receiverType + ", valueParameters=" + this.valueParameters + ", typeParameters=" + this.typeParameters + ", hasStableParameterNames=" + this.hasStableParameterNames + ", errors=" + this.errors + ')';
        }
    }

    public static final class ResolvedValueParameters {

        @kp6
        private final List<ValueParameterDescriptor> descriptors;
        private final boolean hasSynthesizedNames;

        /* JADX WARN: Multi-variable type inference failed */
        public ResolvedValueParameters(@kp6 List<? extends ValueParameterDescriptor> list, boolean z) {
            cr4.g(list, "descriptors");
            this.descriptors = list;
            this.hasSynthesizedNames = z;
        }

        @kp6
        public final List<ValueParameterDescriptor> getDescriptors() {
            return this.descriptors;
        }

        public final boolean getHasSynthesizedNames() {
            return this.hasSynthesizedNames;
        }
    }

    static {
        hk7 hk7Var = new hk7(LazyJavaScope.class, "functionNamesLazy", "getFunctionNamesLazy()Ljava/util/Set;", 0);
        kw7 kw7Var = iw7.a;
        $$delegatedProperties = new KProperty[]{kw7Var.property1(hk7Var), n41.w(LazyJavaScope.class, "propertyNamesLazy", "getPropertyNamesLazy()Ljava/util/Set;", 0, kw7Var), n41.w(LazyJavaScope.class, "classNamesLazy", "getClassNamesLazy()Ljava/util/Set;", 0, kw7Var)};
    }

    public /* synthetic */ LazyJavaScope(LazyJavaResolverContext lazyJavaResolverContext, LazyJavaScope lazyJavaScope, int i, uz1 uz1Var) {
        this(lazyJavaResolverContext, (i & 2) != 0 ? null : lazyJavaScope);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final Collection allDescriptors$lambda$0(LazyJavaScope lazyJavaScope) {
        return lazyJavaScope.computeDescriptors(DescriptorKindFilter.ALL, MemberScope.Companion.getALL_NAME_FILTER());
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final Set classNamesLazy_delegate$lambda$12(LazyJavaScope lazyJavaScope) {
        return lazyJavaScope.computeClassNames(DescriptorKindFilter.CLASSIFIERS, null);
    }

    private final PropertyDescriptorImpl createPropertyDescriptor(JavaField javaField) {
        JavaPropertyDescriptor javaPropertyDescriptorCreate = JavaPropertyDescriptor.create(getOwnerDescriptor(), LazyJavaAnnotationsKt.resolveAnnotations(this.c, javaField), Modality.FINAL, UtilsKt.toDescriptorVisibility(javaField.getVisibility()), !javaField.isFinal(), javaField.getName(), this.c.getComponents().getSourceElementFactory().source(javaField), isFinalStatic(javaField));
        cr4.f(javaPropertyDescriptorCreate, "create(...)");
        return javaPropertyDescriptorCreate;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final PropertyDescriptor declaredField$lambda$3(LazyJavaScope lazyJavaScope, Name name) {
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        LazyJavaScope lazyJavaScope2 = lazyJavaScope.mainScope;
        if (lazyJavaScope2 != null) {
            return (PropertyDescriptor) lazyJavaScope2.declaredField.invoke(name);
        }
        JavaField javaFieldFindFieldByName = ((DeclaredMemberIndex) lazyJavaScope.declaredMemberIndex.invoke()).findFieldByName(name);
        if (javaFieldFindFieldByName == null || javaFieldFindFieldByName.isEnumEntry()) {
            return null;
        }
        return lazyJavaScope.resolveProperty(javaFieldFindFieldByName);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final Collection declaredFunctions$lambda$2(LazyJavaScope lazyJavaScope, Name name) {
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        LazyJavaScope lazyJavaScope2 = lazyJavaScope.mainScope;
        if (lazyJavaScope2 != null) {
            return (Collection) lazyJavaScope2.declaredFunctions.invoke(name);
        }
        ArrayList arrayList = new ArrayList();
        for (JavaMethod javaMethod : ((DeclaredMemberIndex) lazyJavaScope.declaredMemberIndex.invoke()).findMethodsByName(name)) {
            JavaMethodDescriptor javaMethodDescriptorResolveMethodToFunctionDescriptor = lazyJavaScope.resolveMethodToFunctionDescriptor(javaMethod);
            if (lazyJavaScope.isVisibleAsFunction(javaMethodDescriptorResolveMethodToFunctionDescriptor)) {
                lazyJavaScope.c.getComponents().getJavaResolverCache().recordMethod(javaMethod, javaMethodDescriptorResolveMethodToFunctionDescriptor);
                arrayList.add(javaMethodDescriptorResolveMethodToFunctionDescriptor);
            }
        }
        lazyJavaScope.computeImplicitlyDeclaredFunctions(arrayList, name);
        return arrayList;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final Set functionNamesLazy_delegate$lambda$10(LazyJavaScope lazyJavaScope) {
        return lazyJavaScope.computeFunctionNames(DescriptorKindFilter.FUNCTIONS, null);
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final Collection functions$lambda$4(LazyJavaScope lazyJavaScope, Name name) {
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        LinkedHashSet linkedHashSet = new LinkedHashSet((Collection) lazyJavaScope.declaredFunctions.invoke(name));
        lazyJavaScope.retainMostSpecificMethods(linkedHashSet);
        lazyJavaScope.computeNonDeclaredFunctions(linkedHashSet, name);
        return y41.bo(lazyJavaScope.c.getComponents().getSignatureEnhancement().enhanceSignatures(lazyJavaScope.c, linkedHashSet));
    }

    private final Set<Name> getClassNamesLazy() {
        return (Set) StorageKt.getValue(this.classNamesLazy$delegate, this, (KProperty<?>) $$delegatedProperties[2]);
    }

    private final Set<Name> getFunctionNamesLazy() {
        return (Set) StorageKt.getValue(this.functionNamesLazy$delegate, this, (KProperty<?>) $$delegatedProperties[0]);
    }

    private final Set<Name> getPropertyNamesLazy() {
        return (Set) StorageKt.getValue(this.propertyNamesLazy$delegate, this, (KProperty<?>) $$delegatedProperties[1]);
    }

    private final KotlinType getPropertyType(JavaField javaField) {
        KotlinType kotlinTypeTransformJavaType = this.c.getTypeResolver().transformJavaType(javaField.getType(), JavaTypeAttributesKt.toAttributes$default(TypeUsage.COMMON, false, false, null, 7, null));
        if ((!KotlinBuiltIns.isPrimitiveType(kotlinTypeTransformJavaType) && !KotlinBuiltIns.isString(kotlinTypeTransformJavaType)) || !isFinalStatic(javaField) || !javaField.getHasConstantNotNullInitializer()) {
            return kotlinTypeTransformJavaType;
        }
        KotlinType kotlinTypeMakeNotNullable = TypeUtils.makeNotNullable(kotlinTypeTransformJavaType);
        cr4.f(kotlinTypeMakeNotNullable, "makeNotNullable(...)");
        return kotlinTypeMakeNotNullable;
    }

    private final boolean isFinalStatic(JavaField javaField) {
        return javaField.isFinal() && javaField.isStatic();
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final List properties$lambda$13(LazyJavaScope lazyJavaScope, Name name) {
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        ArrayList arrayList = new ArrayList();
        CollectionsKt.addIfNotNull(arrayList, lazyJavaScope.declaredField.invoke(name));
        lazyJavaScope.computeNonDeclaredProperties(name, arrayList);
        return DescriptorUtils.isAnnotationClass(lazyJavaScope.getOwnerDescriptor()) ? y41.bo(arrayList) : y41.bo(lazyJavaScope.c.getComponents().getSignatureEnhancement().enhanceSignatures(lazyJavaScope.c, arrayList));
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final Set propertyNamesLazy_delegate$lambda$11(LazyJavaScope lazyJavaScope) {
        return lazyJavaScope.computePropertyNames(DescriptorKindFilter.VARIABLES, null);
    }

    private final PropertyDescriptor resolveProperty(final JavaField javaField) {
        final dw7.h hVar = new dw7.h();
        PropertyDescriptorImpl propertyDescriptorImplCreatePropertyDescriptor = createPropertyDescriptor(javaField);
        hVar.a = propertyDescriptorImplCreatePropertyDescriptor;
        propertyDescriptorImplCreatePropertyDescriptor.initialize(null, null, null, null);
        KotlinType propertyType = getPropertyType(javaField);
        PropertyDescriptorImpl propertyDescriptorImpl = (PropertyDescriptorImpl) hVar.a;
        ReceiverParameterDescriptor dispatchReceiverParameter = getDispatchReceiverParameter();
        ik2 ik2Var = ik2.a;
        propertyDescriptorImpl.setType(propertyType, ik2Var, dispatchReceiverParameter, null, ik2Var);
        DeclarationDescriptor ownerDescriptor = getOwnerDescriptor();
        ClassDescriptor classDescriptor = ownerDescriptor instanceof ClassDescriptor ? (ClassDescriptor) ownerDescriptor : null;
        if (classDescriptor != null) {
            hVar.a = this.c.getComponents().getSyntheticPartsProvider().modifyField(classDescriptor, (PropertyDescriptorImpl) hVar.a, this.c);
        }
        Object obj = hVar.a;
        if (DescriptorUtils.shouldRecordInitializerForProperty((VariableDescriptor) obj, ((PropertyDescriptorImpl) obj).getType())) {
            ((PropertyDescriptorImpl) hVar.a).setCompileTimeInitializerFactory(new qq3(this, javaField, hVar) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$10
                private final LazyJavaScope arg$0;
                private final JavaField arg$1;
                private final dw7.h arg$2;

                {
                    this.arg$0 = this;
                    this.arg$1 = javaField;
                    this.arg$2 = hVar;
                }

                @Override // defpackage.qq3
                public Object invoke() {
                    return LazyJavaScope.resolveProperty$lambda$16(this.arg$0, this.arg$1, this.arg$2);
                }
            });
        }
        this.c.getComponents().getJavaResolverCache().recordField(javaField, (PropertyDescriptor) hVar.a);
        return (PropertyDescriptor) hVar.a;
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final NullableLazyValue resolveProperty$lambda$16(final LazyJavaScope lazyJavaScope, final JavaField javaField, final dw7.h hVar) {
        return lazyJavaScope.c.getStorageManager().createNullableLazyValue(new qq3(lazyJavaScope, javaField, hVar) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$11
            private final LazyJavaScope arg$0;
            private final JavaField arg$1;
            private final dw7.h arg$2;

            {
                this.arg$0 = lazyJavaScope;
                this.arg$1 = javaField;
                this.arg$2 = hVar;
            }

            @Override // defpackage.qq3
            public Object invoke() {
                return LazyJavaScope.resolveProperty$lambda$16$lambda$15(this.arg$0, this.arg$1, this.arg$2);
            }
        });
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final ConstantValue resolveProperty$lambda$16$lambda$15(LazyJavaScope lazyJavaScope, JavaField javaField, dw7.h hVar) {
        return lazyJavaScope.c.getComponents().getJavaPropertyInitializerEvaluator().getInitializerConstant(javaField, (PropertyDescriptor) hVar.a);
    }

    private final void retainMostSpecificMethods(Set<SimpleFunctionDescriptor> set) {
        LinkedHashMap linkedHashMap = new LinkedHashMap();
        for (Object obj : set) {
            String strComputeJvmDescriptor$default = MethodSignatureMappingKt.computeJvmDescriptor$default((SimpleFunctionDescriptor) obj, false, false, 2, null);
            Object arrayList = linkedHashMap.get(strComputeJvmDescriptor$default);
            if (arrayList == null) {
                arrayList = new ArrayList();
                linkedHashMap.put(strComputeJvmDescriptor$default, arrayList);
            }
            ((List) arrayList).add(obj);
        }
        for (List list : linkedHashMap.values()) {
            if (list.size() != 1) {
                List list2 = list;
                Collection<? extends SimpleFunctionDescriptor> collectionSelectMostSpecificInEachOverridableGroup = OverridingUtilsKt.selectMostSpecificInEachOverridableGroup(list2, new sq3() { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$9
                    @Override // defpackage.sq3
                    public Object invoke(Object obj2) {
                        return LazyJavaScope.retainMostSpecificMethods$lambda$6((SimpleFunctionDescriptor) obj2);
                    }
                });
                set.removeAll(list2);
                set.addAll(collectionSelectMostSpecificInEachOverridableGroup);
            }
        }
    }

    /* JADX INFO: Access modifiers changed from: private */
    public static final CallableDescriptor retainMostSpecificMethods$lambda$6(SimpleFunctionDescriptor simpleFunctionDescriptor) {
        cr4.g(simpleFunctionDescriptor, "$this$selectMostSpecificInEachOverridableGroup");
        return simpleFunctionDescriptor;
    }

    @kp6
    public abstract Set<Name> computeClassNames(@kp6 DescriptorKindFilter descriptorKindFilter, @pq6 sq3<? super Name, Boolean> sq3Var);

    @kp6
    public final List<DeclarationDescriptor> computeDescriptors(@kp6 DescriptorKindFilter descriptorKindFilter, @kp6 sq3<? super Name, Boolean> sq3Var) {
        cr4.g(descriptorKindFilter, "kindFilter");
        cr4.g(sq3Var, "nameFilter");
        NoLookupLocation noLookupLocation = NoLookupLocation.WHEN_GET_ALL_DESCRIPTORS;
        LinkedHashSet linkedHashSet = new LinkedHashSet();
        if (descriptorKindFilter.acceptsKinds(DescriptorKindFilter.Companion.getCLASSIFIERS_MASK())) {
            for (Name name : computeClassNames(descriptorKindFilter, sq3Var)) {
                if (((Boolean) sq3Var.invoke(name)).booleanValue()) {
                    CollectionsKt.addIfNotNull(linkedHashSet, mo172getContributedClassifier(name, noLookupLocation));
                }
            }
        }
        if (descriptorKindFilter.acceptsKinds(DescriptorKindFilter.Companion.getFUNCTIONS_MASK()) && !descriptorKindFilter.getExcludes().contains(DescriptorKindExclude.NonExtensions.INSTANCE)) {
            for (Name name2 : computeFunctionNames(descriptorKindFilter, sq3Var)) {
                if (((Boolean) sq3Var.invoke(name2)).booleanValue()) {
                    linkedHashSet.addAll(getContributedFunctions(name2, noLookupLocation));
                }
            }
        }
        if (descriptorKindFilter.acceptsKinds(DescriptorKindFilter.Companion.getVARIABLES_MASK()) && !descriptorKindFilter.getExcludes().contains(DescriptorKindExclude.NonExtensions.INSTANCE)) {
            for (Name name3 : computePropertyNames(descriptorKindFilter, sq3Var)) {
                if (((Boolean) sq3Var.invoke(name3)).booleanValue()) {
                    linkedHashSet.addAll(getContributedVariables(name3, noLookupLocation));
                }
            }
        }
        return y41.bo(linkedHashSet);
    }

    @kp6
    public abstract Set<Name> computeFunctionNames(@kp6 DescriptorKindFilter descriptorKindFilter, @pq6 sq3<? super Name, Boolean> sq3Var);

    public void computeImplicitlyDeclaredFunctions(@kp6 Collection<SimpleFunctionDescriptor> collection, @kp6 Name name) {
        cr4.g(collection, "result");
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
    }

    @kp6
    public abstract DeclaredMemberIndex computeMemberIndex();

    @kp6
    public final KotlinType computeMethodReturnType(@kp6 JavaMethod javaMethod, @kp6 LazyJavaResolverContext lazyJavaResolverContext) {
        cr4.g(javaMethod, "method");
        cr4.g(lazyJavaResolverContext, "c");
        return lazyJavaResolverContext.getTypeResolver().transformJavaType(javaMethod.getReturnType(), JavaTypeAttributesKt.toAttributes$default(TypeUsage.COMMON, javaMethod.getContainingClass().isAnnotationType(), false, null, 6, null));
    }

    public abstract void computeNonDeclaredFunctions(@kp6 Collection<SimpleFunctionDescriptor> collection, @kp6 Name name);

    public abstract void computeNonDeclaredProperties(@kp6 Name name, @kp6 Collection<PropertyDescriptor> collection);

    @kp6
    public abstract Set<Name> computePropertyNames(@kp6 DescriptorKindFilter descriptorKindFilter, @pq6 sq3<? super Name, Boolean> sq3Var);

    @kp6
    public final NotNullLazyValue<Collection<DeclarationDescriptor>> getAllDescriptors() {
        return this.allDescriptors;
    }

    @kp6
    public final LazyJavaResolverContext getC() {
        return this.c;
    }

    @Override // kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl, kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScope
    @kp6
    public Set<Name> getClassifierNames() {
        return getClassNamesLazy();
    }

    @Override // kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl, kotlin.reflect.jvm.internal.impl.resolve.scopes.ResolutionScope
    @kp6
    public Collection<DeclarationDescriptor> getContributedDescriptors(@kp6 DescriptorKindFilter descriptorKindFilter, @kp6 sq3<? super Name, Boolean> sq3Var) {
        cr4.g(descriptorKindFilter, "kindFilter");
        cr4.g(sq3Var, "nameFilter");
        return (Collection) this.allDescriptors.invoke();
    }

    @Override // kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl, kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScope, kotlin.reflect.jvm.internal.impl.resolve.scopes.ResolutionScope
    @kp6
    public Collection<SimpleFunctionDescriptor> getContributedFunctions(@kp6 Name name, @kp6 LookupLocation lookupLocation) {
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        cr4.g(lookupLocation, "location");
        return !getFunctionNames().contains(name) ? ik2.a : (Collection) this.functions.invoke(name);
    }

    @Override // kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl, kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScope
    @kp6
    public Collection<PropertyDescriptor> getContributedVariables(@kp6 Name name, @kp6 LookupLocation lookupLocation) {
        cr4.g(name, AppMeasurementSdk.ConditionalUserProperty.NAME);
        cr4.g(lookupLocation, "location");
        return !getVariableNames().contains(name) ? ik2.a : (Collection) this.properties.invoke(name);
    }

    @kp6
    public final NotNullLazyValue<DeclaredMemberIndex> getDeclaredMemberIndex() {
        return this.declaredMemberIndex;
    }

    @pq6
    public abstract ReceiverParameterDescriptor getDispatchReceiverParameter();

    @Override // kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl, kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScope
    @kp6
    public Set<Name> getFunctionNames() {
        return getFunctionNamesLazy();
    }

    @pq6
    public final LazyJavaScope getMainScope() {
        return this.mainScope;
    }

    @kp6
    public abstract DeclarationDescriptor getOwnerDescriptor();

    @Override // kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScopeImpl, kotlin.reflect.jvm.internal.impl.resolve.scopes.MemberScope
    @kp6
    public Set<Name> getVariableNames() {
        return getPropertyNamesLazy();
    }

    public boolean isVisibleAsFunction(@kp6 JavaMethodDescriptor javaMethodDescriptor) {
        cr4.g(javaMethodDescriptor, "<this>");
        return true;
    }

    @kp6
    public abstract MethodSignatureData resolveMethodSignature(@kp6 JavaMethod javaMethod, @kp6 List<? extends TypeParameterDescriptor> list, @kp6 KotlinType kotlinType, @kp6 List<? extends ValueParameterDescriptor> list2);

    @kp6
    public final JavaMethodDescriptor resolveMethodToFunctionDescriptor(@kp6 JavaMethod javaMethod) {
        cr4.g(javaMethod, "method");
        JavaMethodDescriptor javaMethodDescriptorCreateJavaMethod = JavaMethodDescriptor.createJavaMethod(getOwnerDescriptor(), LazyJavaAnnotationsKt.resolveAnnotations(this.c, javaMethod), javaMethod.getName(), this.c.getComponents().getSourceElementFactory().source(javaMethod), ((DeclaredMemberIndex) this.declaredMemberIndex.invoke()).findRecordComponentByName(javaMethod.getName()) != null && javaMethod.getValueParameters().isEmpty());
        cr4.f(javaMethodDescriptorCreateJavaMethod, "createJavaMethod(...)");
        LazyJavaResolverContext lazyJavaResolverContextChildForMethod$default = ContextKt.childForMethod$default(this.c, javaMethodDescriptorCreateJavaMethod, javaMethod, 0, 4, null);
        List<JavaTypeParameter> typeParameters = javaMethod.getTypeParameters();
        List<? extends TypeParameterDescriptor> arrayList = new ArrayList<>(y41.p(typeParameters, 10));
        Iterator<T> it = typeParameters.iterator();
        while (it.hasNext()) {
            TypeParameterDescriptor typeParameterDescriptorResolveTypeParameter = lazyJavaResolverContextChildForMethod$default.getTypeParameterResolver().resolveTypeParameter((JavaTypeParameter) it.next());
            cr4.d(typeParameterDescriptorResolveTypeParameter);
            arrayList.add(typeParameterDescriptorResolveTypeParameter);
        }
        ResolvedValueParameters resolvedValueParametersResolveValueParameters = resolveValueParameters(lazyJavaResolverContextChildForMethod$default, javaMethodDescriptorCreateJavaMethod, javaMethod.getValueParameters());
        MethodSignatureData methodSignatureDataResolveMethodSignature = resolveMethodSignature(javaMethod, arrayList, computeMethodReturnType(javaMethod, lazyJavaResolverContextChildForMethod$default), resolvedValueParametersResolveValueParameters.getDescriptors());
        KotlinType receiverType = methodSignatureDataResolveMethodSignature.getReceiverType();
        javaMethodDescriptorCreateJavaMethod.initialize(receiverType != null ? DescriptorFactory.createExtensionReceiverParameterForCallable(javaMethodDescriptorCreateJavaMethod, receiverType, Annotations.Companion.getEMPTY()) : null, getDispatchReceiverParameter(), ik2.a, methodSignatureDataResolveMethodSignature.getTypeParameters(), methodSignatureDataResolveMethodSignature.getValueParameters(), methodSignatureDataResolveMethodSignature.getReturnType(), Modality.Companion.convertFromFlags(false, javaMethod.isAbstract(), true ^ javaMethod.isFinal()), UtilsKt.toDescriptorVisibility(javaMethod.getVisibility()), methodSignatureDataResolveMethodSignature.getReceiverType() != null ? wo5.i(new q07(JavaMethodDescriptor.ORIGINAL_VALUE_PARAMETER_FOR_EXTENSION_RECEIVER, y41.z(resolvedValueParametersResolveValueParameters.getDescriptors()))) : jk2.a);
        javaMethodDescriptorCreateJavaMethod.setParameterNamesStatus(methodSignatureDataResolveMethodSignature.getHasStableParameterNames(), resolvedValueParametersResolveValueParameters.getHasSynthesizedNames());
        if (!methodSignatureDataResolveMethodSignature.getErrors().isEmpty()) {
            lazyJavaResolverContextChildForMethod$default.getComponents().getSignaturePropagator().reportSignatureErrors(javaMethodDescriptorCreateJavaMethod, methodSignatureDataResolveMethodSignature.getErrors());
        }
        return javaMethodDescriptorCreateJavaMethod;
    }

    @kp6
    public final ResolvedValueParameters resolveValueParameters(@kp6 LazyJavaResolverContext lazyJavaResolverContext, @kp6 FunctionDescriptor functionDescriptor, @kp6 List<? extends JavaValueParameter> list) {
        q07 q07Var;
        Name name;
        cr4.g(lazyJavaResolverContext, "c");
        FunctionDescriptor functionDescriptor2 = functionDescriptor;
        cr4.g(functionDescriptor2, "function");
        cr4.g(list, "jValueParameters");
        il4 il4VarBs = y41.bs(list);
        ArrayList arrayList = new ArrayList(y41.p(il4VarBs, 10));
        Iterator it = il4VarBs.iterator();
        boolean z = false;
        while (true) {
            jl4 jl4Var = (jl4) it;
            if (!jl4Var.a.hasNext()) {
                return new ResolvedValueParameters(y41.bo(arrayList), z);
            }
            hl4 hl4Var = (hl4) jl4Var.next();
            int i = hl4Var.a;
            JavaValueParameter javaValueParameter = (JavaValueParameter) hl4Var.b;
            Annotations annotationsResolveAnnotations = LazyJavaAnnotationsKt.resolveAnnotations(lazyJavaResolverContext, javaValueParameter);
            JavaTypeAttributes attributes$default = JavaTypeAttributesKt.toAttributes$default(TypeUsage.COMMON, false, false, null, 7, null);
            if (javaValueParameter.isVararg()) {
                JavaType type = javaValueParameter.getType();
                JavaArrayType javaArrayType = type instanceof JavaArrayType ? (JavaArrayType) type : null;
                if (javaArrayType == null) {
                    throw new AssertionError("Vararg parameter should be an array: " + javaValueParameter);
                }
                KotlinType kotlinTypeTransformArrayType = lazyJavaResolverContext.getTypeResolver().transformArrayType(javaArrayType, attributes$default, true);
                q07Var = new q07(kotlinTypeTransformArrayType, lazyJavaResolverContext.getModule().getBuiltIns().getArrayElementType(kotlinTypeTransformArrayType));
            } else {
                q07Var = new q07(lazyJavaResolverContext.getTypeResolver().transformJavaType(javaValueParameter.getType(), attributes$default), null);
            }
            KotlinType kotlinType = (KotlinType) q07Var.a;
            KotlinType kotlinType2 = (KotlinType) q07Var.b;
            if (cr4.b(functionDescriptor2.getName().asString(), "equals") && list.size() == 1 && cr4.b(lazyJavaResolverContext.getModule().getBuiltIns().getNullableAnyType(), kotlinType)) {
                name = Name.identifier("other");
            } else {
                name = javaValueParameter.getName();
                if (name == null) {
                    z = true;
                }
                if (name == null) {
                    name = Name.identifier(TtmlNode.TAG_P + i);
                    cr4.f(name, "identifier(...)");
                }
            }
            boolean z2 = z;
            cr4.d(name);
            arrayList.add(new ValueParameterDescriptorImpl(functionDescriptor2, null, i, annotationsResolveAnnotations, name, kotlinType, false, false, false, kotlinType2, lazyJavaResolverContext.getComponents().getSourceElementFactory().source(javaValueParameter)));
            functionDescriptor2 = functionDescriptor;
            z = z2;
        }
    }

    @kp6
    public String toString() {
        return "Lazy scope for " + getOwnerDescriptor();
    }

    public LazyJavaScope(@kp6 LazyJavaResolverContext lazyJavaResolverContext, @pq6 LazyJavaScope lazyJavaScope) {
        cr4.g(lazyJavaResolverContext, "c");
        this.c = lazyJavaResolverContext;
        this.mainScope = lazyJavaScope;
        this.allDescriptors = lazyJavaResolverContext.getStorageManager().createRecursionTolerantLazyValue(new qq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$0
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.qq3
            public Object invoke() {
                return LazyJavaScope.allDescriptors$lambda$0(this.arg$0);
            }
        }, ik2.a);
        this.declaredMemberIndex = lazyJavaResolverContext.getStorageManager().createLazyValue(new qq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$1
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.qq3
            public Object invoke() {
                return this.arg$0.computeMemberIndex();
            }
        });
        this.declaredFunctions = lazyJavaResolverContext.getStorageManager().createMemoizedFunction(new sq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$2
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.sq3
            public Object invoke(Object obj) {
                return LazyJavaScope.declaredFunctions$lambda$2(this.arg$0, (Name) obj);
            }
        });
        this.declaredField = lazyJavaResolverContext.getStorageManager().createMemoizedFunctionWithNullableValues(new sq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$3
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.sq3
            public Object invoke(Object obj) {
                return LazyJavaScope.declaredField$lambda$3(this.arg$0, (Name) obj);
            }
        });
        this.functions = lazyJavaResolverContext.getStorageManager().createMemoizedFunction(new sq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$4
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.sq3
            public Object invoke(Object obj) {
                return LazyJavaScope.functions$lambda$4(this.arg$0, (Name) obj);
            }
        });
        this.functionNamesLazy$delegate = lazyJavaResolverContext.getStorageManager().createLazyValue(new qq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$5
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.qq3
            public Object invoke() {
                return LazyJavaScope.functionNamesLazy_delegate$lambda$10(this.arg$0);
            }
        });
        this.propertyNamesLazy$delegate = lazyJavaResolverContext.getStorageManager().createLazyValue(new qq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$6
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.qq3
            public Object invoke() {
                return LazyJavaScope.propertyNamesLazy_delegate$lambda$11(this.arg$0);
            }
        });
        this.classNamesLazy$delegate = lazyJavaResolverContext.getStorageManager().createLazyValue(new qq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$7
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.qq3
            public Object invoke() {
                return LazyJavaScope.classNamesLazy_delegate$lambda$12(this.arg$0);
            }
        });
        this.properties = lazyJavaResolverContext.getStorageManager().createMemoizedFunction(new sq3(this) { // from class: kotlin.reflect.jvm.internal.impl.load.java.lazy.descriptors.LazyJavaScope$$Lambda$8
            private final LazyJavaScope arg$0;

            {
                this.arg$0 = this;
            }

            @Override // defpackage.sq3
            public Object invoke(Object obj) {
                return LazyJavaScope.properties$lambda$13(this.arg$0, (Name) obj);
            }
        });
    }
}
