FIR IDE: add info about nullability to KtType
This commit is contained in:
@@ -19,11 +19,23 @@ interface KtType : ValidityTokenOwner {
|
|||||||
fun asStringForDebugging(): String
|
fun asStringForDebugging(): String
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface KtTypeWithNullability : KtType {
|
||||||
|
val nullability: KtTypeNullability
|
||||||
|
}
|
||||||
|
|
||||||
|
enum class KtTypeNullability {
|
||||||
|
NULLABLE, NON_NULLABLE;
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun create(isNullable: Boolean) = if (isNullable) NULLABLE else NON_NULLABLE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sealed class KtDenotableType : KtType {
|
sealed class KtDenotableType : KtType {
|
||||||
abstract fun asString(): String
|
abstract fun asString(): String
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KtClassType : KtDenotableType() {
|
abstract class KtClassType : KtDenotableType(), KtTypeWithNullability {
|
||||||
abstract val classId: ClassId
|
abstract val classId: ClassId
|
||||||
abstract val classSymbol: KtClassLikeSymbol
|
abstract val classSymbol: KtClassLikeSymbol
|
||||||
abstract val typeArguments: List<KtTypeArgument>
|
abstract val typeArguments: List<KtTypeArgument>
|
||||||
@@ -33,7 +45,7 @@ abstract class KtErrorType : KtType {
|
|||||||
abstract val error: String
|
abstract val error: String
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class KtTypeParameterType : KtDenotableType() {
|
abstract class KtTypeParameterType : KtDenotableType(), KtTypeWithNullability {
|
||||||
abstract val name: Name
|
abstract val name: Name
|
||||||
abstract val symbol: KtTypeParameterSymbol
|
abstract val symbol: KtTypeParameterSymbol
|
||||||
}
|
}
|
||||||
|
|||||||
+3
@@ -65,6 +65,7 @@ internal class KtFirClassType(
|
|||||||
firBuilder.buildTypeArgument(typeArgument)
|
firBuilder.buildTypeArgument(typeArgument)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
override val nullability: KtTypeNullability get() = withValidityAssertion { KtTypeNullability.create(coneType.isNullable) }
|
||||||
|
|
||||||
override fun asString(): String = withValidityAssertion {
|
override fun asString(): String = withValidityAssertion {
|
||||||
coneType.render() //todo
|
coneType.render() //todo
|
||||||
@@ -97,6 +98,8 @@ internal class KtFirTypeParameterType(
|
|||||||
?: error("Type parameter ${coneType.lookupTag} was not found")
|
?: error("Type parameter ${coneType.lookupTag} was not found")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val nullability: KtTypeNullability get() = withValidityAssertion { KtTypeNullability.create(coneType.isNullable) }
|
||||||
|
|
||||||
override fun asString(): String = withValidityAssertion {
|
override fun asString(): String = withValidityAssertion {
|
||||||
coneType.render() //todo
|
coneType.render() //todo
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user