diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/InternalFlexibleTypeTransformer.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/InternalFlexibleTypeTransformer.kt index 72873674616..a7270b88f17 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/InternalFlexibleTypeTransformer.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/InternalFlexibleTypeTransformer.kt @@ -34,7 +34,7 @@ object InternalFlexibleTypeTransformer : TypeTransformerForTests() { val descriptor = kotlinType.constructor.declarationDescriptor if (descriptor != null && FLEXIBLE_TYPE_CLASSIFIER.asSingleFqName().toUnsafe() == DescriptorUtils.getFqName(descriptor) && kotlinType.arguments.size == 2) { - return KotlinTypeFactory.flexibleType(kotlinType.arguments[0].type.asSimpleType(), kotlinType.arguments[1].type.asSimpleType()) + return KotlinTypeFactory.flexibleType(kotlinType.arguments[0].type.unwrap() as SimpleType, kotlinType.arguments[1].type.unwrap() as SimpleType) } return null } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java index e6999c57cb6..3cd5da729d7 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java @@ -86,7 +86,7 @@ public class SingleAbstractMethodUtils { assert type != null : "Substitution based on type with no projections '" + noProjectionsSamType + "' should not end with conflict"; - SimpleType simpleType = KotlinTypeKt.asSimpleType(type); + SimpleType simpleType = TypeSubstitutionKt.asSimpleType(type); return simpleType.makeNullableAsSpecified(samType.isMarkedNullable()); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java index 372fab94088..fd607e4704e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DescriptorResolver.java @@ -736,16 +736,17 @@ public class DescriptorResolver { else { typeAliasDescriptor.initialize( typeParameterDescriptors, - DeferredType.create(storageManager, trace, new Function0() { + storageManager.createLazyValue(new Function0() { @Override - public KotlinType invoke() { + public SimpleType invoke() { return typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace, true); } }), - DeferredType.create(storageManager, trace, new Function0() { + storageManager.createLazyValue(new Function0() { @Override - public KotlinType invoke() { - return typeResolver.resolveExpandedTypeForTypeAlias(typeAliasDescriptor); + public SimpleType invoke() { + // TODO do not reparse + return typeResolver.resolveAbbreviatedType(scopeWithTypeParameters, typeReference, trace, false); } })); } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java index b01194a0bbd..a351b28819a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PossiblyBareType.java @@ -94,12 +94,12 @@ public class PossiblyBareType { KotlinType nullableActualType = TypeUtils.makeNullable(getActualType()); - KotlinType abbreviatedType = SpecialTypesKt.getAbbreviatedType(getActualType()); + AbbreviatedType abbreviatedType = SpecialTypesKt.getAbbreviatedType(getActualType()); if (abbreviatedType == null) { return type(nullableActualType); } else { - return type(SpecialTypesKt.withAbbreviatedType(KotlinTypeKt.asSimpleType(nullableActualType), KotlinTypeKt.asSimpleType(TypeUtils.makeNullable(abbreviatedType)))); + return type(abbreviatedType.makeNullableAsSpecified(true)); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 1c2270c48e4..8b65b5855c7 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -71,8 +71,20 @@ class TypeResolver( return resolveType(TypeResolutionContext(scope, trace, checkBounds, false, typeReference.suppressDiagnosticsInDebugMode(), false), typeReference) } - fun resolveAbbreviatedType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, checkBounds: Boolean): KotlinType { - return resolveType(TypeResolutionContext(scope, trace, checkBounds, false, typeReference.suppressDiagnosticsInDebugMode(), true), typeReference) + fun resolveAbbreviatedType(scope: LexicalScope, typeReference: KtTypeReference, trace: BindingTrace, abbreviated: Boolean): SimpleType { + return resolveSimpleType( + TypeResolutionContext(scope, trace, true, false, typeReference.suppressDiagnosticsInDebugMode(), abbreviated), + typeReference + ) + } + + private fun resolveSimpleType(c: TypeResolutionContext, typeReference: KtTypeReference): SimpleType { + val unwrappedType = resolveType(c, typeReference).unwrap() + return when (unwrappedType) { + is DynamicType -> ErrorUtils.createErrorType("dynamic type in wrong context") + is SimpleType -> unwrappedType + else -> error("Unexpected type: $unwrappedType") + } } fun resolveExpandedTypeForTypeAlias(typeAliasDescriptor: TypeAliasDescriptor): KotlinType { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeAliasDescriptor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeAliasDescriptor.kt index d4c465e6dc0..2098f188997 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeAliasDescriptor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyTypeAliasDescriptor.kt @@ -21,11 +21,12 @@ import org.jetbrains.kotlin.descriptors.annotations.Annotations import org.jetbrains.kotlin.descriptors.impl.AbstractTypeAliasDescriptor import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.BindingTrace +import org.jetbrains.kotlin.storage.NotNullLazyValue import org.jetbrains.kotlin.storage.StorageManager -import org.jetbrains.kotlin.types.DeferredType -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.SimpleType import org.jetbrains.kotlin.types.TypeSubstitutor import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.asSimpleType class LazyTypeAliasDescriptor( private val storageManager: StorageManager, @@ -38,33 +39,43 @@ class LazyTypeAliasDescriptor( ) : AbstractTypeAliasDescriptor(containingDeclaration, annotations, name, sourceElement, visibility), TypeAliasDescriptor { - override lateinit var underlyingType: KotlinType private set - override lateinit var expandedType: KotlinType private set + private lateinit var underlyingTypeImpl: NotNullLazyValue + private lateinit var expandedTypeImpl: NotNullLazyValue + + override val underlyingType: SimpleType get() = underlyingTypeImpl() + override val expandedType: SimpleType get() = expandedTypeImpl() + + fun initialize( + declaredTypeParameters: List, + lazyUnderlyingType: NotNullLazyValue, + lazyExpandedType: NotNullLazyValue + ) { + super.initialize(declaredTypeParameters) + this.underlyingTypeImpl = lazyUnderlyingType + this.expandedTypeImpl = lazyExpandedType + } private val lazyTypeConstructorParameters = storageManager.createLazyValue { this.computeConstructorTypeParameters() } fun initialize( declaredTypeParameters: List, - underlyingType: KotlinType, - expandedType: KotlinType - ) { - super.initialize(declaredTypeParameters) - this.underlyingType = underlyingType - this.expandedType = expandedType - } + underlyingType: SimpleType, + expandedType: SimpleType + ) = initialize(declaredTypeParameters, storageManager.createLazyValue { underlyingType }, storageManager.createLazyValue { expandedType }) override fun substitute(substitutor: TypeSubstitutor): TypeAliasDescriptor { if (substitutor.isEmpty) return this val substituted = LazyTypeAliasDescriptor(storageManager, trace, containingDeclaration, annotations, name, source, visibility) substituted.initialize(declaredTypeParameters, - DeferredType.create(storageManager, trace) { - substitutor.substitute(underlyingType, Variance.INVARIANT) - }, - DeferredType.create(storageManager, trace) { - substitutor.substitute(expandedType, Variance.INVARIANT) - }) + storageManager.createLazyValue { + substitutor.substitute(underlyingType, Variance.INVARIANT)!!.asSimpleType() + }, + storageManager.createLazyValue { + substitutor.substitute(expandedType, Variance.INVARIANT)!!.asSimpleType() + } + ) return substituted } diff --git a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java index af3d5843329..393f0f9939b 100644 --- a/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java +++ b/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.java @@ -377,7 +377,7 @@ public class DescriptorSerializer { builder.addTypeParameter(typeParameter(typeParameterDescriptor)); } - KotlinType underlyingType = descriptor.getUnderlyingType(); + SimpleType underlyingType = descriptor.getUnderlyingType(); if (useTypeTable()) { builder.setUnderlyingTypeId(typeId(underlyingType)); } @@ -385,7 +385,7 @@ public class DescriptorSerializer { builder.setUnderlyingType(type(underlyingType)); } - KotlinType expandedType = descriptor.getExpandedType(); + SimpleType expandedType = descriptor.getExpandedType(); if (useTypeTable()) { builder.setExpandedTypeId(typeId(expandedType)); } @@ -548,13 +548,13 @@ public class DescriptorSerializer { builder.setNullable(type.isMarkedNullable()); } - KotlinType abbreviatedType = SpecialTypesKt.getAbbreviatedType(type); + AbbreviatedType abbreviatedType = SpecialTypesKt.getAbbreviatedType(type); if (abbreviatedType != null) { if (useTypeTable()) { - builder.setAbbreviatedTypeId(typeId(abbreviatedType)); + builder.setAbbreviatedTypeId(typeId(abbreviatedType.getAbbreviation())); } else { - builder.setAbbreviatedType(type(abbreviatedType)); + builder.setAbbreviatedType(type(abbreviatedType.getAbbreviation())); } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeAliasDescriptor.kt b/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeAliasDescriptor.kt index ffe27c0aa38..9c784176957 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeAliasDescriptor.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/TypeAliasDescriptor.kt @@ -16,13 +16,13 @@ package org.jetbrains.kotlin.descriptors -import org.jetbrains.kotlin.types.KotlinType +import org.jetbrains.kotlin.types.SimpleType import org.jetbrains.kotlin.types.TypeSubstitutor interface TypeAliasDescriptor : ClassifierDescriptorWithTypeParameters, MemberDescriptor { - val underlyingType: KotlinType + val underlyingType: SimpleType - val expandedType: KotlinType + val expandedType: SimpleType val classDescriptor: ClassDescriptor? diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index 057184ffe1b..d45571846e5 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -123,12 +123,12 @@ internal class DescriptorRendererImpl( } private fun renderNormalizedType(type: KotlinType): String { - val abbreviated = type.getAbbreviatedType() + val abbreviated = (type.unwrap() as? AbbreviatedType) if (abbreviated != null) { // TODO nullability is lost for abbreviated type? - val abbreviatedRendered = renderNormalizedTypeAsIs(abbreviated) - val unabbreviatedRendered = renderNormalizedTypeAsIs(type) + val abbreviatedRendered = renderNormalizedTypeAsIs(abbreviated.abbreviation) + val unabbreviatedRendered = renderNormalizedTypeAsIs(abbreviated.expandedType) return "$abbreviatedRendered [= $unabbreviatedRendered]" } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt index 8d011b1301c..642112a8204 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/KotlinType.kt @@ -136,7 +136,3 @@ abstract class FlexibleType(val lowerBound: SimpleType, val upperBound: SimpleTy override fun toString(): String = DescriptorRenderer.DEBUG_TEXT.renderType(this) } -@Deprecated("Temporary marker method for refactoring") -fun KotlinType.asSimpleType(): SimpleType { - return unwrap() as SimpleType -} diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt index 81dd26125b4..aeab26e8d29 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/SpecialTypes.kt @@ -29,19 +29,21 @@ abstract class DelegatingSimpleType : SimpleType() { override val memberScope: MemberScope get() = delegate.memberScope } -private class AbbreviatedType(override val delegate: SimpleType, val abbreviatedType: SimpleType) : DelegatingSimpleType() { +class AbbreviatedType(override val delegate: SimpleType, val abbreviation: SimpleType) : DelegatingSimpleType() { + val expandedType: SimpleType get() = delegate + override fun replaceAnnotations(newAnnotations: Annotations) - = AbbreviatedType(delegate.replaceAnnotations(newAnnotations), abbreviatedType) + = AbbreviatedType(delegate.replaceAnnotations(newAnnotations), abbreviation) override fun makeNullableAsSpecified(newNullability: Boolean) - = AbbreviatedType(delegate.makeNullableAsSpecified(newNullability), abbreviatedType.makeNullableAsSpecified(newNullability)) + = AbbreviatedType(delegate.makeNullableAsSpecified(newNullability), abbreviation.makeNullableAsSpecified(newNullability)) override val isError: Boolean get() = false } -fun KotlinType.getAbbreviatedType(): SimpleType? = (unwrap() as? AbbreviatedType)?.abbreviatedType +fun KotlinType.getAbbreviatedType(): AbbreviatedType? = (unwrap() as? AbbreviatedType) -fun SimpleType.withAbbreviatedType(abbreviatedType: SimpleType): SimpleType { +fun SimpleType.withAbbreviation(abbreviatedType: SimpleType): SimpleType { if (isError) return this return AbbreviatedType(this, abbreviatedType) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt index c504301f92d..8cbb1b348b7 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitution.kt @@ -173,3 +173,8 @@ open class DelegatedTypeSubstitution(val substitution: TypeSubstitution): TypeSu override fun filterAnnotations(annotations: Annotations) = substitution.filterAnnotations(annotations) } + +// This method used for transform type to simple type afler substitution +fun KotlinType.asSimpleType(): SimpleType { + return unwrap() as? SimpleType ?: error("This is should be simple type: $this") +} diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java index 2ef166be718..3238f31ba73 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/kotlin/types/TypeSubstitutor.java @@ -152,7 +152,7 @@ public class TypeSubstitutor { "Unexpected substituted projection kind: " + substitutedProjectionKind + "; original: " + originalProjectionKind; KotlinType substitutedFlexibleType = KotlinTypeFactory.flexibleType( - KotlinTypeKt.asSimpleType(substitutedLower.getType()), KotlinTypeKt.asSimpleType(substitutedUpper.getType())); + TypeSubstitutionKt.asSimpleType(substitutedLower.getType()), TypeSubstitutionKt.asSimpleType(substitutedUpper.getType())); return new TypeProjectionImpl(substitutedProjectionKind, substitutedFlexibleType); } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt index a19a4e92752..c71d14e7934 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/DeserializedType.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedAnnotationsWithPossibleTargets import org.jetbrains.kotlin.types.AbstractLazyType import org.jetbrains.kotlin.types.SimpleType -import org.jetbrains.kotlin.types.withAbbreviatedType +import org.jetbrains.kotlin.types.withAbbreviation import org.jetbrains.kotlin.utils.toReadOnlyList class DeserializedType private constructor( @@ -58,7 +58,7 @@ class DeserializedType private constructor( val deserializedType = DeserializedType(c, typeProto, additionalAnnotations) val abbreviatedTypeProto = typeProto.abbreviatedType(c.typeTable) ?: return deserializedType - return deserializedType.withAbbreviatedType(DeserializedType(c, abbreviatedTypeProto, additionalAnnotations)) + return deserializedType.withAbbreviation(DeserializedType(c, abbreviatedTypeProto, additionalAnnotations)) } } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt index 380c6a74ac1..66a12d6a159 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/MemberDeserializer.kt @@ -180,8 +180,8 @@ class MemberDeserializer(private val c: DeserializationContext) { val local = c.childContext(typeAlias, proto.typeParameterList) typeAlias.initialize( local.typeDeserializer.ownTypeParameters, - local.typeDeserializer.type(proto.underlyingType(c.typeTable)), - local.typeDeserializer.type(proto.expandedType(c.typeTable)) + local.typeDeserializer.simpleType(proto.underlyingType(c.typeTable)), + local.typeDeserializer.simpleType(proto.expandedType(c.typeTable)) ) return typeAlias diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt index 6d3ac528683..4e72dce98bf 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/TypeDeserializer.kt @@ -58,14 +58,17 @@ class TypeDeserializer( fun type(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY): KotlinType { if (proto.hasFlexibleTypeCapabilitiesId()) { val id = c.nameResolver.getString(proto.flexibleTypeCapabilitiesId) - val lowerBound = DeserializedType.create(c, proto, additionalAnnotations) - val upperBound = DeserializedType.create(c, proto.flexibleUpperBound(c.typeTable)!!, additionalAnnotations) + val lowerBound = simpleType(proto, additionalAnnotations) + val upperBound = simpleType(proto.flexibleUpperBound(c.typeTable)!!, additionalAnnotations) return c.components.flexibleTypeDeserializer.create(proto, id, lowerBound, upperBound) } - return DeserializedType.create(c, proto, additionalAnnotations) + return simpleType(proto, additionalAnnotations) } + fun simpleType(proto: ProtoBuf.Type, additionalAnnotations: Annotations = Annotations.EMPTY) + = DeserializedType.create(c, proto, additionalAnnotations) + fun typeConstructor(proto: ProtoBuf.Type): TypeConstructor = when { proto.hasClassName() -> { diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt index 81b15d95c8e..f0c36d11b13 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt @@ -24,9 +24,7 @@ import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.serialization.ProtoBuf import org.jetbrains.kotlin.serialization.deserialization.NameResolver import org.jetbrains.kotlin.serialization.deserialization.TypeTable -import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.types.TypeSubstitutor -import org.jetbrains.kotlin.types.Variance +import org.jetbrains.kotlin.types.* interface DeserializedMemberDescriptor : MemberDescriptor { val proto: MessageLite @@ -154,14 +152,14 @@ class DeserializedTypeAliasDescriptor( ) : AbstractTypeAliasDescriptor(containingDeclaration, annotations, name, SourceElement.NO_SOURCE, visibility), DeserializedMemberDescriptor { - override lateinit var underlyingType: KotlinType private set - override lateinit var expandedType: KotlinType private set + override lateinit var underlyingType: SimpleType private set + override lateinit var expandedType: SimpleType private set private lateinit var typeConstructorParameters: List fun initialize( declaredTypeParameters: List, - underlyingType: KotlinType, - expandedType: KotlinType + underlyingType: SimpleType, + expandedType: SimpleType ) { initialize(declaredTypeParameters) this.underlyingType = underlyingType @@ -173,8 +171,8 @@ class DeserializedTypeAliasDescriptor( if (substitutor.isEmpty) return this val substituted = DeserializedTypeAliasDescriptor(containingDeclaration, annotations, name, visibility, proto, nameResolver, typeTable, containerSource) substituted.initialize(declaredTypeParameters, - substitutor.safeSubstitute(underlyingType, Variance.INVARIANT), - substitutor.safeSubstitute(expandedType, Variance.INVARIANT)) + substitutor.safeSubstitute(underlyingType, Variance.INVARIANT).asSimpleType(), + substitutor.safeSubstitute(expandedType, Variance.INVARIANT).asSimpleType()) return substituted }