Introduce an API to convert TypeConstructorMarker to TypeParameterMarker

This commit is contained in:
Jinseong Jeon
2021-10-19 11:04:54 -07:00
committed by teamcity
parent a367b91aa1
commit 2dc2a90755
5 changed files with 22 additions and 3 deletions
@@ -28,11 +28,19 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping(
override fun TypeConstructorMarker.isTypeParameter(): Boolean {
require(this is TypeConstructor)
return when (this) {
is NewTypeVariableConstructor -> true
is NewTypeVariableConstructor -> originalTypeParameter != null
else -> declarationDescriptor is TypeParameterDescriptor
}
}
override fun TypeConstructorMarker.asTypeParameter(): TypeParameterMarker {
require(this is TypeConstructor)
return when (this) {
is NewTypeVariableConstructor -> originalTypeParameter!!
else -> declarationDescriptor as TypeParameterDescriptor
}
}
override fun TypeConstructorMarker.defaultType(): KotlinTypeMarker {
require(this is TypeConstructor)
val declaration = declarationDescriptor ?: return ErrorUtils.createErrorType("Unresolved declaration descriptor ($this)")
@@ -104,4 +112,4 @@ internal class KtFe10TypeSystemCommonBackendContextForTypeMapping(
override fun functionNTypeConstructor(n: Int): TypeConstructorMarker {
return builtIns.getKFunction(n).typeConstructor
}
}
}