From 3abfe59d75f7d2051635b66c39c3b04374d7f76f Mon Sep 17 00:00:00 2001 From: Dmitry Savvinov Date: Thu, 17 Oct 2019 14:30:33 +0300 Subject: [PATCH] Deduplicate incompatible actual descriptors Otherwise, we might get false positive AMBIGUOUS_ACTUALS due to one and the same descriptor appearing multiple times in a list --- .../resolve/checkers/ExpectedActualDeclarationChecker.kt | 7 ++++++- .../top/top.kt | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt index a19621689c0..caac5b873ec 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/ExpectedActualDeclarationChecker.kt @@ -138,7 +138,12 @@ class ExpectedActualDeclarationChecker( } // Several compatible actuals on one path: report AMBIGUIOUS_ACTUALS here - val atLeastWeaklyCompatibleActuals = compatibility.filterKeys { it.isCompatibleOrWeakCompatible() }.values.flatten() + val atLeastWeaklyCompatibleActuals = compatibility + .filterKeys { it.isCompatibleOrWeakCompatible() } + .values + .flatten() + .distinct() + if (atLeastWeaklyCompatibleActuals.size > 1) { trace.report(Errors.AMBIGUOUS_ACTUALS.on( reportOn, diff --git a/idea/testData/multiModuleHighlighting/hierarchicalExpectActualMatching/weaklyIncompatibleActualInIntermediateModule/top/top.kt b/idea/testData/multiModuleHighlighting/hierarchicalExpectActualMatching/weaklyIncompatibleActualInIntermediateModule/top/top.kt index 54bf6400c61..f385c7d7ea1 100644 --- a/idea/testData/multiModuleHighlighting/hierarchicalExpectActualMatching/weaklyIncompatibleActualInIntermediateModule/top/top.kt +++ b/idea/testData/multiModuleHighlighting/hierarchicalExpectActualMatching/weaklyIncompatibleActualInIntermediateModule/top/top.kt @@ -1,5 +1,5 @@ package sample -expect class A { +expect class A { fun f() } \ No newline at end of file