diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt index 9bcf42f222f..a57fd1e3ced 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.kt @@ -16,14 +16,14 @@ class A { } -class B : A { - override fun rest(s: String) {} +class B : A { + override fun rest(s: String) {} - fun rest(s: String) {} + fun rest(s: String) {} fun rest(l: Long) {} - override val u = 310 + override val u = 310 } interface B diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.ll.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.ll.kt deleted file mode 100644 index 7f568ff4361..00000000000 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/conflictingOverloads.ll.kt +++ /dev/null @@ -1,75 +0,0 @@ -// LL_FIR_DIVERGENCE -// The compiler doesn't specify which declaration of `A` is chosen in supertype resolution given that `A` has multiple redeclarations. -// LL_FIR_DIVERGENCE - -fun test(x: Int) {} - -fun test(y: Int) {} - -fun test() {} - -fun test(z: Int, c: Char) {} - -open class A { - open fun rest(s: String) {} - - open val u = 20 -} - -class A { - -} - -class B : A { - override fun rest(s: String) {} - - fun rest(s: String) {} - - fun rest(l: Long) {} - - override val u = 310 -} - -interface B - -enum class B - -val u = 10 -val u = 20 - -val (a,b) = 30 to 40 -val (c,d) = 50 to 60 - -typealias TA = A -typealias TA = B - -typealias BA = A - -fun <T> kek(t: T) where T : (String) -> Any?, T : Char {} -fun <T> kek(t: T) where T : () -> Boolean, T : String {} -fun Int> kek(t: T) {} - -fun lol(a: Array) {} -fun lol(a: Array) {} - -fun <T> mem(t: T) where T : () -> Boolean, T : String {} -fun <T> mem(t: T) where T : String, T : () -> Boolean {} - -class M { - companion object {} - val Companion = object : Any() {} -} - -fun B.foo() {} - -class L { - fun B.foo() {} -} - -fun mest() {} - -class mest - -fun() {} - -private fun() {} diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt index ffc342bda1f..4f2eb3ec70f 100644 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt +++ b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.kt @@ -6,7 +6,7 @@ interface C : A interface D : C, A -class E : B, A() +class E : B, A() sealed class P { object H: P() diff --git a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.ll.kt b/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.ll.kt deleted file mode 100644 index 1d67793eacd..00000000000 --- a/compiler/fir/analysis-tests/testData/resolve/diagnostics/sealedSupertype.ll.kt +++ /dev/null @@ -1,45 +0,0 @@ -// LL_FIR_DIVERGENCE -// The compiler doesn't specify which declaration of `B` is chosen in supertype resolution given that `B` is declared both as a class and -// as an object. -// LL_FIR_DIVERGENCE - -sealed class A - -class B : A() - -interface C : A - -interface D : C, A - -class E : B, A() - -sealed class P { - object H: P() - class J : P() - - object T { - object V : P() - class M : P() - } - - val p: P = object : P() { - - } - - val r = object : P() { - - } -} - -class K : P() - -object B { - class I : P() -} - -fun test() { - class L : P() - val a = object : P() { - - } -} diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirProviderImpl.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirProviderImpl.kt index b93f9a5cf74..ec6277f9ed8 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirProviderImpl.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/providers/impl/FirProviderImpl.kt @@ -123,8 +123,12 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli override fun visitRegularClass(regularClass: FirRegularClass, data: FirRecorderData) { val classId = regularClass.symbol.classId val prevFile = data.state.classifierContainerFileMap.put(classId, data.file) - data.state.classifierMap.put(classId, regularClass)?.let { - data.nameConflictsTracker?.registerClassifierRedeclaration(classId, regularClass.symbol, data.file, it.symbol, prevFile) + val storedClassifier = data.state.classifierMap.getOrPut(classId) { regularClass } + + if (storedClassifier != regularClass) { + data.nameConflictsTracker?.registerClassifierRedeclaration( + classId, regularClass.symbol, data.file, storedClassifier.symbol, prevFile, + ) } if (!classId.isNestedClass && !classId.isLocal) { @@ -138,8 +142,12 @@ class FirProviderImpl(val session: FirSession, val kotlinScopeProvider: FirKotli override fun visitTypeAlias(typeAlias: FirTypeAlias, data: FirRecorderData) { val classId = typeAlias.symbol.classId val prevFile = data.state.classifierContainerFileMap.put(classId, data.file) - data.state.classifierMap.put(classId, typeAlias)?.let { - data.nameConflictsTracker?.registerClassifierRedeclaration(classId, typeAlias.symbol, data.file, it.symbol, prevFile) + val storedClassifier = data.state.classifierMap.getOrPut(classId) { typeAlias } + + if (storedClassifier != typeAlias) { + data.nameConflictsTracker?.registerClassifierRedeclaration( + classId, typeAlias.symbol, data.file, storedClassifier.symbol, prevFile, + ) } data.state.classifierInPackage.getOrPut(classId.packageFqName, ::mutableSetOf).add(classId.shortClassName) diff --git a/compiler/testData/cli/metadata/inheritorOfExpectSealedClass.out b/compiler/testData/cli/metadata/inheritorOfExpectSealedClass.out index c086a087a40..4321a1c10ef 100644 --- a/compiler/testData/cli/metadata/inheritorOfExpectSealedClass.out +++ b/compiler/testData/cli/metadata/inheritorOfExpectSealedClass.out @@ -1,4 +1,7 @@ compiler/testData/cli/metadata/inheritorOfExpectSealedClass/common-2.kt:1:21: error: 'actual class Base : Any' has no corresponding expected declaration actual sealed class Base ^ +compiler/testData/cli/metadata/inheritorOfExpectSealedClass/common-3.kt:1:17: error: unresolved reference ''. +class Derived : Base() + ^ COMPILATION_ERROR diff --git a/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt b/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt index 5b245a25ea2..6e66b77537e 100644 --- a/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/privateInFile.fir.kt @@ -6,16 +6,16 @@ private class C { private typealias TA = C private val test1: C = C() -private val test1co: C.Companion = C +private val test1co: C.Companion = C private val test2: TA = TA() private val test2co = TA // FILE: file2.kt private val test1: C = C() -private val test1co: C.Companion = C +private val test1co: C.Companion = C -private val test2: TA = TA() +private val test2: TA = TA() private val test2co = TA private class C