diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java index 187afd7e2d8..2428b4c8ff2 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ImplementationBodyCodegen.java @@ -302,7 +302,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { private JvmClassSignature signature() { BothSignatureWriter sw = new BothSignatureWriter(BothSignatureWriter.Mode.CLASS); - typeMapper.writeFormalTypeParameters(descriptor.getTypeConstructor().getParameters(), sw); + typeMapper.writeFormalTypeParameters(descriptor.getDeclaredTypeParameters(), sw); sw.writeSuperclass(); if (superClassType == null) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/MutableClassDescriptor.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/MutableClassDescriptor.java index 26b5774d6bb..fc3d1d14a3c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/MutableClassDescriptor.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/MutableClassDescriptor.java @@ -143,6 +143,12 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class this.typeParameters = new ArrayList(typeParameters); } + @NotNull + @Override + public List getDeclaredTypeParameters() { + return typeParameters; + } + public void createTypeConstructor() { assert typeConstructor == null : typeConstructor; this.typeConstructor = TypeConstructorImpl.createForClass( diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt index fdb70c38285..8f7a27836e8 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/resolve/jvm/checkers/declarationCheckers.kt @@ -195,7 +195,7 @@ public class TypeParameterBoundIsNotArrayChecker : DeclarationChecker { bindingContext: BindingContext ) { val typeParameters = (descriptor as? CallableDescriptor)?.typeParameters - ?: (descriptor as? ClassDescriptor)?.typeConstructor?.parameters + ?: (descriptor as? ClassDescriptor)?.declaredTypeParameters ?: return for (typeParameter in typeParameters) { @@ -222,7 +222,7 @@ public class ReifiedTypeParameterAnnotationChecker : DeclarationChecker { } if (descriptor is ClassDescriptor) { - checkTypeParameterDescriptorsAreNotReified(descriptor.getTypeConstructor().getParameters(), diagnosticHolder) + checkTypeParameterDescriptorsAreNotReified(descriptor.declaredTypeParameters, diagnosticHolder) } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt index 3b63f4f1680..e5c847adf50 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt @@ -117,7 +117,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : BaseImportingSc //TODO: non-inner classes for (parent in ownerClass.parentsWithSelf) { if (parent !is ClassDescriptor) break - sourceTypeParams += parent.typeConstructor.parameters + sourceTypeParams += parent.declaredTypeParameters } //TODO: duplicated parameter names diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index beb5addfe4c..bfa725014f2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -252,7 +252,7 @@ public class DeclarationsChecker { EffectiveVisibility classVisibility = EffectiveVisibility.Companion.forClass(classDescriptor); List typeParameterList = klass.getTypeParameters(); int i = 0; - for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) { + for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getDeclaredTypeParameters()) { if (i >= typeParameterList.size()) return; for (KotlinType upperBound : typeParameterDescriptor.getUpperBounds()) { EffectiveVisibility upperBoundVisibility = EffectiveVisibility.Companion.forType(upperBound); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt index 4667f615b83..77ec35a0e09 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/VarianceChecker.kt @@ -96,7 +96,7 @@ class VarianceChecker(private val trace: BindingTrace) { val containingClass = descriptor.getContainingDeclaration() if (containingClass !is ClassDescriptor) return true - return containingClass.getTypeConstructor().getParameters().all { it.getVariance() == INVARIANT } + return containingClass.typeConstructor.parameters.all { it.getVariance() == INVARIANT } } private fun recordPrivateToThis(descriptor: CallableMemberDescriptor) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt index 170072754f5..e54766b263f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/ClassResolutionScopesSupport.kt @@ -37,7 +37,7 @@ class ClassResolutionScopesSupport( ) { private fun scopeWithGenerics(parent: LexicalScope, debugName: String): LexicalScopeImpl { return LexicalScopeImpl(parent, classDescriptor, false, null, debugName) { - classDescriptor.typeConstructor.parameters.forEach { addClassifierDescriptor(it) } + classDescriptor.declaredTypeParameters.forEach { addClassifierDescriptor(it) } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index 67283a6924d..ba836e5a5e5 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -101,9 +101,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes private final boolean isCompanionObject; private final ClassResolutionScopesSupport resolutionScopesSupport; + private final NotNullLazyValue> parameters; public LazyClassDescriptor( - @NotNull LazyClassContext c, + @NotNull final LazyClassContext c, @NotNull DeclarationDescriptor containingDeclaration, @NotNull Name name, @NotNull JetClassLikeInfo classLikeInfo @@ -239,6 +240,30 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return getOuterScope(); } }, classLikeInfo.getPrimaryConstructorParameters()); + + this.parameters = c.getStorageManager().createLazyValue(new Function0>() { + @Override + public List invoke() { + JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo(); + KtTypeParameterList typeParameterList = classInfo.getTypeParameterList(); + if (typeParameterList == null) return Collections.emptyList(); + + if (classInfo.getClassKind() == ClassKind.ENUM_CLASS) { + c.getTrace().report(TYPE_PARAMETERS_IN_ENUM.on(typeParameterList)); + } + + List typeParameters = typeParameterList.getParameters(); + + List parameters = new ArrayList(typeParameters.size()); + + for (int i = 0; i < typeParameters.size(); i++) { + parameters.add(new LazyTypeParameterDescriptor(c, LazyClassDescriptor.this, typeParameters.get(i), i)); + } + + return parameters; + } + }); + } // NOTE: Called from constructor! @@ -489,6 +514,12 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes getVisibility(); } + @NotNull + @Override + public List getDeclaredTypeParameters() { + return parameters.invoke(); + } + private static class Supertypes { @Mutable public final Collection trueSupertypes; @@ -545,21 +576,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes private final NotNullLazyValue> parameters = c.getStorageManager().createLazyValue(new Function0>() { @Override public List invoke() { - JetClassLikeInfo classInfo = declarationProvider.getOwnerInfo(); - KtTypeParameterList typeParameterList = classInfo.getTypeParameterList(); - if (typeParameterList == null) return Collections.emptyList(); - - if (classInfo.getClassKind() == ClassKind.ENUM_CLASS) { - c.getTrace().report(TYPE_PARAMETERS_IN_ENUM.on(typeParameterList)); - } - - List typeParameters = typeParameterList.getParameters(); - List parameters = new ArrayList(typeParameters.size()); - for (int i = 0; i < typeParameters.size(); i++) { - parameters.add(new LazyTypeParameterDescriptor(c, LazyClassDescriptor.this, typeParameters.get(i), i)); - } - - return parameters; + return LazyClassDescriptor.this.getDeclaredTypeParameters(); } }); diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java index 35c6a00a798..bcec0ca676b 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java @@ -104,7 +104,7 @@ public class DescriptorSerializer { new MutableTypeTable(), false ); - for (TypeParameterDescriptor typeParameter : descriptor.getTypeConstructor().getParameters()) { + for (TypeParameterDescriptor typeParameter : descriptor.getDeclaredTypeParameters()) { serializer.typeParameters.intern(typeParameter); } return serializer; @@ -137,7 +137,7 @@ public class DescriptorSerializer { builder.setFqName(getClassId(classDescriptor)); - for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) { + for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getDeclaredTypeParameters()) { builder.addTypeParameter(typeParameter(typeParameterDescriptor)); } diff --git a/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java b/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java index 329b337190a..df7a840a29e 100644 --- a/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java +++ b/compiler/tests/org/jetbrains/kotlin/test/util/DescriptorValidator.java @@ -234,7 +234,7 @@ public class DescriptorValidator { public Boolean visitClassDescriptor( ClassDescriptor descriptor, DiagnosticCollector collector ) { - validateTypeParameters(collector, descriptor.getTypeConstructor().getParameters()); + validateTypeParameters(collector, descriptor.getDeclaredTypeParameters()); Collection supertypes = descriptor.getTypeConstructor().getSupertypes(); if (supertypes.isEmpty() && descriptor.getKind() != ClassKind.INTERFACE diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt index c9847a363c5..3d5df28148a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassDescriptor.kt @@ -112,6 +112,16 @@ class LazyJavaClassDescriptor( } } + private val declaredParameters = c.storageManager.createLazyValue { + jClass.typeParameters.map { + p -> + c.typeParameterResolver.resolveTypeParameter(p) + ?: throw AssertionError("Parameter $p surely belongs to class $jClass, so it must be resolved") + } + } + + override fun getDeclaredTypeParameters() = declaredParameters() + override fun getFunctionTypeForSamInterface(): KotlinType? = functionTypeForSamInterface() override fun isCompanionObject() = false @@ -121,11 +131,7 @@ class LazyJavaClassDescriptor( private inner class LazyJavaClassTypeConstructor : AbstractClassTypeConstructor() { private val parameters = c.storageManager.createLazyValue { - jClass.getTypeParameters().map { - p -> - c.typeParameterResolver.resolveTypeParameter(p) - ?: throw AssertionError("Parameter $p surely belongs to class $jClass, so it must be resolved") - } + this@LazyJavaClassDescriptor.declaredTypeParameters } override fun getParameters(): List = parameters() diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt index 54d1f22fd2b..f0440332076 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionClassDescriptor.kt @@ -66,6 +66,26 @@ public class FunctionClassDescriptor( private val typeConstructor = FunctionTypeConstructor() private val memberScope = FunctionClassScope(storageManager, this) + private val parameters: List + + init { + val result = ArrayList() + + fun typeParameter(variance: Variance, name: String) { + result.add(TypeParameterDescriptorImpl.createWithDefaultBound( + this@FunctionClassDescriptor, Annotations.EMPTY, false, variance, Name.identifier(name), result.size() + )) + } + + (1..arity).map { i -> + typeParameter(Variance.IN_VARIANCE, "P$i") + } + + typeParameter(Variance.OUT_VARIANCE, "R") + + parameters = result.toReadOnlyList() + } + override fun getContainingDeclaration() = containingDeclaration override fun getStaticScope() = staticScope @@ -86,26 +106,9 @@ public class FunctionClassDescriptor( override fun getAnnotations() = Annotations.EMPTY override fun getSource() = SourceElement.NO_SOURCE + override fun getDeclaredTypeParameters() = parameters + private inner class FunctionTypeConstructor : AbstractClassTypeConstructor() { - private val parameters: List - - init { - val result = ArrayList() - - fun typeParameter(variance: Variance, name: String) { - result.add(TypeParameterDescriptorImpl.createWithDefaultBound( - this@FunctionClassDescriptor, Annotations.EMPTY, false, variance, Name.identifier(name), result.size() - )) - } - - (1..arity).map { i -> - typeParameter(Variance.IN_VARIANCE, "P$i") - } - - typeParameter(Variance.OUT_VARIANCE, "R") - - parameters = result.toReadOnlyList() - } private val supertypes = storageManager.createLazyValue { val result = ArrayList(2) @@ -138,7 +141,7 @@ public class FunctionClassDescriptor( result.toReadOnlyList() } - override fun getParameters() = parameters + override fun getParameters() = this@FunctionClassDescriptor.parameters override fun getSupertypes(): Collection = supertypes() diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt index b23d423bc54..b4113095009 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/functions/FunctionInvokeDescriptor.kt @@ -56,7 +56,7 @@ public class FunctionInvokeDescriptor private constructor( companion object Factory { fun create(functionClass: FunctionClassDescriptor): FunctionInvokeDescriptor { - val typeParameters = functionClass.getTypeConstructor().getParameters() + val typeParameters = functionClass.declaredTypeParameters val result = FunctionInvokeDescriptor(functionClass, null, CallableMemberDescriptor.Kind.DECLARATION) result.initialize( diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java index c41959d3b57..274dacb34b9 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/ClassDescriptor.java @@ -94,4 +94,13 @@ public interface ClassDescriptor extends ClassifierDescriptor, MemberDescriptor, @Nullable ConstructorDescriptor getUnsubstitutedPrimaryConstructor(); + + /** + * It may differ from 'typeConstructor.parameters' in current class is inner, 'typeConstructor.parameters' contains + * captured parameters from outer declaration. + * @return list of type parameters actually declared type parameters in current class + */ + @ReadOnly + @NotNull + List getDeclaredTypeParameters(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java index de36b6deb3b..78d294a9c55 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ClassDescriptorImpl.java @@ -30,6 +30,7 @@ import org.jetbrains.kotlin.types.TypeConstructorImpl; import java.util.Collection; import java.util.Collections; +import java.util.List; import java.util.Set; public class ClassDescriptorImpl extends ClassDescriptorBase { @@ -147,4 +148,10 @@ public class ClassDescriptorImpl extends ClassDescriptorBase { public String toString() { return "class " + getName(); } + + @NotNull + @Override + public List getDeclaredTypeParameters() { + return Collections.emptyList(); + } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java index 787f0dfdacd..ecd2f78b8b7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/EnumEntrySyntheticClassDescriptor.java @@ -39,10 +39,7 @@ import org.jetbrains.kotlin.types.TypeConstructor; import org.jetbrains.kotlin.types.TypeConstructorImpl; import org.jetbrains.kotlin.utils.Printer; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; +import java.util.*; public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { private final TypeConstructor typeConstructor; @@ -172,6 +169,12 @@ public class EnumEntrySyntheticClassDescriptor extends ClassDescriptorBase { return "enum entry " + getName(); } + @NotNull + @Override + public List getDeclaredTypeParameters() { + return Collections.emptyList(); + } + private class EnumEntryScope extends MemberScopeImpl { private final MemoizedFunctionToNotNull> functions; private final MemoizedFunctionToNotNull> properties; diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java index 1b9eb9afe46..61b0fcb5bd0 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/LazySubstitutingClassDescriptor.java @@ -33,7 +33,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { private final ClassDescriptor original; private final TypeSubstitutor originalSubstitutor; private TypeSubstitutor newSubstitutor; - private List typeParameters; + private List typeConstructorParameters; private TypeConstructor typeConstructor; public LazySubstitutingClassDescriptor(ClassDescriptor descriptor, TypeSubstitutor substitutor) { @@ -48,9 +48,9 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { } else { List originalTypeParameters = original.getTypeConstructor().getParameters(); - typeParameters = new ArrayList(originalTypeParameters.size()); + typeConstructorParameters = new ArrayList(originalTypeParameters.size()); newSubstitutor = DescriptorSubstitutor.substituteTypeParameters( - originalTypeParameters, originalSubstitutor.getSubstitution(), this, typeParameters + originalTypeParameters, originalSubstitutor.getSubstitution(), this, typeConstructorParameters ); } } @@ -79,7 +79,7 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { originalTypeConstructor.getAnnotations(), originalTypeConstructor.isFinal(), originalTypeConstructor.toString(), - typeParameters, + typeConstructorParameters, supertypes ); } @@ -248,4 +248,11 @@ public class LazySubstitutingClassDescriptor implements ClassDescriptor { public SourceElement getSource() { return SourceElement.NO_SOURCE; } + + @NotNull + @Override + public List getDeclaredTypeParameters() { + getSubstitutor(); + return typeConstructorParameters; + } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 7ef500fd2dd..28513981207 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -619,7 +619,7 @@ internal class DescriptorRendererImpl( val classDescriptor = constructor.getContainingDeclaration() builder.append(" ") renderName(classDescriptor, builder) - renderTypeParameters(classDescriptor.getTypeConstructor().getParameters(), builder, false) + renderTypeParameters(classDescriptor.declaredTypeParameters, builder, false) } renderValueParameters(constructor.valueParameters, constructor.hasSynthesizedParameterNames(), builder) @@ -792,7 +792,7 @@ internal class DescriptorRendererImpl( if (isEnumEntry) return - val typeParameters = klass.typeConstructor.getParameters() + val typeParameters = klass.declaredTypeParameters renderTypeParameters(typeParameters, builder, false) if (!klass.kind.isSingleton && classWithPrimaryConstructor) { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index b9c6a0fc704..d550d0b1cfd 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -166,6 +166,8 @@ public class DeserializedClassDescriptor( override fun getSource() = sourceElement + override fun getDeclaredTypeParameters() = c.typeDeserializer.ownTypeParameters + private inner class DeserializedClassTypeConstructor : AbstractClassTypeConstructor() { private val supertypes = c.storageManager.createLazyValue { computeSupertypes() diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt index 7e8dbf89051..4c13b88d409 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/kdoc/KDocReference.kt @@ -134,7 +134,7 @@ private fun getClassInnerScope(outerScope: LexicalScope, descriptor: ClassDescri val headerScope = LexicalScopeImpl(outerScope, descriptor, false, descriptor.thisAsReceiverParameter, "Class ${descriptor.getName()} header scope") { - for (typeParameter in descriptor.getTypeConstructor().getParameters()) { + for (typeParameter in descriptor.declaredTypeParameters) { addClassifierDescriptor(typeParameter) } for (constructor in descriptor.getConstructors()) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt index aaf264233ad..8f889cdd9ae 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/project/ResolveElementCache.kt @@ -327,7 +327,7 @@ public class ResolveElementCache( val declaration = jetTypeConstraint.getParentOfType(true)!! val descriptor = analyzer.resolveToDescriptor(declaration) as ClassDescriptor - for (parameterDescriptor in descriptor.getTypeConstructor().getParameters()) { + for (parameterDescriptor in descriptor.declaredTypeParameters) { ForceResolveUtil.forceResolveAllContents(parameterDescriptor) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt index 69616158cab..3a130cd40ba 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/BasicLookupElementFactory.kt @@ -166,7 +166,7 @@ class BasicLookupElementFactory( } is ClassDescriptor -> { - val typeParams = descriptor.getTypeConstructor().getParameters() + val typeParams = descriptor.declaredTypeParameters if (includeClassTypeArguments && typeParams.isNotEmpty()) { element = element.appendTailText(typeParams.map { it.getName().asString() }.joinToString(", ", "<", ">"), true) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt index 3e0583dca2c..16c22fb02b0 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/TypeInstantiationItems.kt @@ -295,7 +295,7 @@ class TypeInstantiationItems( private val freeParameters: Collection, private val tail: Tail?) : InheritanceItemsSearcher { - private val baseHasTypeArgs = classDescriptor.typeConstructor.parameters.isNotEmpty() + private val baseHasTypeArgs = classDescriptor.declaredTypeParameters.isNotEmpty() private val expectedType = KotlinTypeImpl.create(Annotations.EMPTY, classDescriptor, false, typeArgs) private val expectedFuzzyType = FuzzyType(expectedType, freeParameters) @@ -309,7 +309,7 @@ class TypeInstantiationItems( if (!visibilityFilter(descriptor)) continue var inheritorFuzzyType = FuzzyType(descriptor.defaultType, descriptor.typeConstructor.parameters) - val hasTypeArgs = descriptor.getTypeConstructor().getParameters().isNotEmpty() + val hasTypeArgs = descriptor.declaredTypeParameters.isNotEmpty() if (hasTypeArgs || baseHasTypeArgs) { val substitutor = inheritorFuzzyType.checkIsSubtypeOf(expectedFuzzyType) ?: continue if (!substitutor.isEmpty) { diff --git a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt index 1c65166da71..e14bb317684 100644 --- a/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt +++ b/idea/src/org/jetbrains/kotlin/idea/actions/generate/KotlinGenerateEqualsAndHashcodeAction.kt @@ -184,7 +184,7 @@ class KotlinGenerateEqualsAndHashcodeAction : KotlinGenerateMemberActionBase()