Do subtyping between self types with captured type in special way
This commit is contained in:
@@ -168,6 +168,28 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
|
||||
override fun TypeParameterMarker.getTypeConstructor() = this as IrTypeParameterSymbol
|
||||
|
||||
private fun KotlinTypeMarker.containsTypeConstructor(constructor: TypeConstructorMarker): Boolean {
|
||||
if (this.typeConstructor() == constructor) return true
|
||||
|
||||
for (i in 0 until this.argumentsCount()) {
|
||||
val typeArgument = this.getArgument(i).takeIf { !it.isStarProjection() } ?: continue
|
||||
if (typeArgument.getType().containsTypeConstructor(constructor)) return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun TypeParameterMarker.doesFormSelfType(selfConstructor: TypeConstructorMarker): Boolean {
|
||||
for (i in 0 until this.upperBoundCount()) {
|
||||
val upperBound = this.getUpperBound(i)
|
||||
if (upperBound.containsTypeConstructor(selfConstructor) && upperBound.typeConstructor() == selfConstructor) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
override fun areEqualTypeConstructors(c1: TypeConstructorMarker, c2: TypeConstructorMarker): Boolean =
|
||||
if (c1 is IrClassifierSymbol && c2 is IrClassifierSymbol) {
|
||||
FqNameEqualityChecker.areEqual(c1 , c2)
|
||||
@@ -277,6 +299,9 @@ interface IrTypeSystemContext : TypeSystemContext, TypeSystemCommonSuperTypesCon
|
||||
return this.owner.classId?.isLocal == true
|
||||
}
|
||||
|
||||
override val TypeVariableTypeConstructorMarker.typeParameter: TypeParameterMarker?
|
||||
get() = error("Type variables is unsupported in IR")
|
||||
|
||||
override fun createFlexibleType(lowerBound: SimpleTypeMarker, upperBound: SimpleTypeMarker): KotlinTypeMarker {
|
||||
require(lowerBound.isNothing())
|
||||
require(upperBound is IrType && upperBound.isNullableAny())
|
||||
|
||||
Reference in New Issue
Block a user