From 024fd9e21a0fa73def1291d3f302654861cc97f0 Mon Sep 17 00:00:00 2001 From: Vladimir Sukharev Date: Wed, 13 Sep 2023 12:58:15 +0000 Subject: [PATCH] [FIR JS] Don't raise diagnostic PROPERTY_AS_OPERATOR for dynamic types. ^KT-60043 Fixed Merge-request: KT-MR-12161 Merged-by: Vladimir Sukharev --- .../checkers/expression/FirConventionFunctionCallChecker.kt | 3 +++ .../testsWithJsStdLib/dynamicTypes/conventions.fir.kt | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirConventionFunctionCallChecker.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirConventionFunctionCallChecker.kt index e6579875770..567343da9e0 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirConventionFunctionCallChecker.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/expression/FirConventionFunctionCallChecker.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.fir.references.FirErrorNamedReference import org.jetbrains.kotlin.fir.expressions.unwrapSmartcastExpression import org.jetbrains.kotlin.fir.resolve.diagnostics.ConePropertyAsOperator import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError +import org.jetbrains.kotlin.fir.types.ConeDynamicType import org.jetbrains.kotlin.util.OperatorNameConventions import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull @@ -43,6 +44,8 @@ object FirConventionFunctionCallChecker : FirFunctionCallChecker() { context: CheckerContext, reporter: DiagnosticReporter ) { + if (callExpression.dispatchReceiver?.coneTypeOrNull is ConeDynamicType) return + // KT-61905: TODO: Return also in case of error type. val sourceKind = callExpression.source?.kind if (sourceKind !is KtRealSourceElementKind && sourceKind !is KtFakeSourceElementKind.GeneratedComparisonExpression && diff --git a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.fir.kt index ae2872bfe52..0370e578520 100644 --- a/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.fir.kt +++ b/compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/conventions.fir.kt @@ -37,7 +37,7 @@ fun test(d: dynamic) { val plus: dynamic = null } - C() + 5 // todo should be marked as DEBUG_INFO_DYNAMIC + C() + 5 // todo should be marked as DEBUG_INFO_DYNAMIC C().plus(5) d == d