From 85c65e20b351825770c4f1792d9d79eaf2484642 Mon Sep 17 00:00:00 2001 From: Ilya Kirillov Date: Fri, 18 Dec 2020 13:09:07 +0100 Subject: [PATCH] FIR: add meaningful error message when type ref is unresolved --- .../tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt index d3f114085c1..d0f4e6af615 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/FirTypeUtils.kt @@ -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 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)