From 0108f8a1b45fb5fd8cce09e25a7fb50bc22c0eea Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Tue, 9 Mar 2021 18:10:02 +0300 Subject: [PATCH] [FIR2IR] Don't create implicit not null cast on IrGetEnumValue --- .../kotlin/fir/backend/Fir2IrImplicitCastInserter.kt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt index f72e42869ea..faaffaf03bf 100644 --- a/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt +++ b/compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrImplicitCastInserter.kt @@ -230,11 +230,10 @@ class Fir2IrImplicitCastInserter( canBeNull || hasEnhancedNullability() private fun IrExpression.insertImplicitNotNullCastIfNeeded(expression: FirExpression): IrExpression { + if (this is IrGetEnumValue) return this // [TypeOperatorLowering] will retrieve the source (from start offset to end offset) as an assertion message. // Avoid type casting if we can't determine the source for some reasons, e.g., implicit `this` receiver. - if (expression.source == null) { - return this - } + if (expression.source == null) return this // Cast type massage 1. Remove @EnhancedNullability // Cast type massage 2. Convert it to a non-null variant (in case of @FlexibleNullability) val castType = type.removeAnnotations {