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