Inner type aliases.
Type alias is considered "inner" if it captures outer class type parameters (implicitly or explicitly).
This commit is contained in:
+10
-4
@@ -47,14 +47,20 @@ abstract class AbstractTypeAliasDescriptor(
|
||||
visitor.visitTypeAliasDescriptor(this, data)
|
||||
|
||||
override fun isInner(): Boolean =
|
||||
containingDeclaration !is PackageFragmentDescriptor
|
||||
// NB: it's ok to use underlyingType here, since referenced inner type aliases also capture type parameters.
|
||||
// Using expandedType looks "proper", but in fact will cause a recursion in expandedType resolution,
|
||||
// which will silently produce wrong result.
|
||||
TypeUtils.contains(underlyingType) {
|
||||
!it.isError && run {
|
||||
val constructorDescriptor = it.constructor.declarationDescriptor
|
||||
constructorDescriptor is TypeParameterDescriptor &&
|
||||
constructorDescriptor.containingDeclaration != this@AbstractTypeAliasDescriptor
|
||||
}
|
||||
}
|
||||
|
||||
override fun getDeclaredTypeParameters(): List<TypeParameterDescriptor> =
|
||||
declaredTypeParametersImpl
|
||||
|
||||
override val classDescriptor: ClassDescriptor?
|
||||
get() = if (expandedType.isError) null else expandedType.constructor.declarationDescriptor as? ClassDescriptor
|
||||
|
||||
override fun getModality() = Modality.FINAL
|
||||
|
||||
override fun getVisibility() = visibilityImpl
|
||||
|
||||
+2
@@ -133,6 +133,8 @@ class NotFoundClasses(private val storageManager: StorageManager, private val mo
|
||||
get() = builtIns.nullableAnyType
|
||||
override fun getDefaultType(): SimpleType =
|
||||
builtIns.nullableAnyType
|
||||
override val classDescriptor: ClassDescriptor?
|
||||
get() = expandedType.constructor.declarationDescriptor as? ClassDescriptor
|
||||
|
||||
override fun substitute(substitutor: TypeSubstitutor) = this
|
||||
|
||||
|
||||
+3
@@ -169,6 +169,9 @@ class DeserializedTypeAliasDescriptor(
|
||||
defaultTypeImpl = computeDefaultType()
|
||||
}
|
||||
|
||||
override val classDescriptor: ClassDescriptor?
|
||||
get() = if (expandedType.isError) null else expandedType.constructor.declarationDescriptor as? ClassDescriptor
|
||||
|
||||
override fun getDefaultType(): SimpleType =
|
||||
defaultTypeImpl
|
||||
|
||||
|
||||
Reference in New Issue
Block a user