FIR serializer: throw exception on getting ConeCapturedType

This commit assumes that captured types are forbidden
at the end of resolve, at least in public API
This commit is contained in:
Mikhail Glukhikh
2020-09-17 13:52:52 +03:00
parent 83ee705c0a
commit 104f088d4e

View File

@@ -552,7 +552,6 @@ class FirElementSerializer private constructor(
private fun typeProto(typeRef: FirTypeRef, toSuper: Boolean = false): ProtoBuf.Type.Builder {
val approximatedType = when (typeRef.coneType) {
is ConeIntegerLiteralType,
is ConeCapturedType,
is ConeDefinitelyNotNullType,
is ConeIntersectionType ->
typeRef.approximated(typeApproximator, toSuper)
@@ -599,7 +598,6 @@ class FirElementSerializer private constructor(
builder.typeParameter = getTypeParameterId(typeParameter)
}
}
is ConeCapturedType,
is ConeDefinitelyNotNullType,
is ConeIntersectionType,
is ConeIntegerLiteralType -> {
@@ -609,6 +607,9 @@ class FirElementSerializer private constructor(
}
return typeProto(approximatedType as ConeKotlinType)
}
is ConeCapturedType -> {
throw IllegalStateException("Captured types should not persist up to the serializer: ${type.render()}")
}
else -> {
throw AssertionError("Should not be here: ${type::class.java}")
}