FIR: add meaningful error message when type ref is unresolved

This commit is contained in:
Ilya Kirillov
2020-12-18 13:09:07 +01:00
parent 6ad396f417
commit 85c65e20b3
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.fir.types
import org.jetbrains.kotlin.fir.expressions.FirAnnotationCall
import org.jetbrains.kotlin.fir.expressions.FirConstKind
import org.jetbrains.kotlin.fir.render
import org.jetbrains.kotlin.fir.symbols.StandardClassIds
import org.jetbrains.kotlin.fir.types.impl.FirImplicitBuiltinTypeRef
import org.jetbrains.kotlin.name.ClassId
@@ -23,7 +24,9 @@ inline fun <reified T : ConeKotlinType> FirTypeRef.coneTypeSafe(): T? {
return (this as? FirResolvedTypeRef)?.type as? T
}
inline val FirTypeRef.coneType: ConeKotlinType get() = coneTypeUnsafe()
inline val FirTypeRef.coneType: ConeKotlinType
get() = coneTypeSafe()
?: error("Expected FirResolvedTypeRef with ConeKotlinType but was ${this::class.simpleName} ${render()}")
val FirTypeRef.isAny: Boolean get() = isBuiltinType(StandardClassIds.Any, false)
val FirTypeRef.isNullableAny: Boolean get() = isBuiltinType(StandardClassIds.Any, true)