K2 JVM: Take JVM declarations conflicting error back
Since SimpleDiagnosticsCollectorWithSuppress have been replaced by
PendingDiagnosticsCollectorWithSuppress after commit 9add6f3d55,
diagnostics need to be committed now.
#KT-54366 Fixed
This commit is contained in:
@@ -38,6 +38,10 @@ open class KtDiagnosticReporterWithContext(
|
|||||||
) : DiagnosticReporter() {
|
) : DiagnosticReporter() {
|
||||||
override fun report(diagnostic: KtDiagnostic?, context: DiagnosticContext) = diagnosticReporter.report(diagnostic, context)
|
override fun report(diagnostic: KtDiagnostic?, context: DiagnosticContext) = diagnosticReporter.report(diagnostic, context)
|
||||||
|
|
||||||
|
override fun checkAndCommitReportsOn(element: AbstractKtSourceElement, context: DiagnosticContext?) {
|
||||||
|
diagnosticReporter.checkAndCommitReportsOn(element, context)
|
||||||
|
}
|
||||||
|
|
||||||
open fun at(sourceElement: AbstractKtSourceElement?, containingFilePath: String): DiagnosticContextImpl =
|
open fun at(sourceElement: AbstractKtSourceElement?, containingFilePath: String): DiagnosticContextImpl =
|
||||||
DiagnosticContextImpl(sourceElement, containingFilePath)
|
DiagnosticContextImpl(sourceElement, containingFilePath)
|
||||||
|
|
||||||
@@ -81,6 +85,13 @@ open class KtDiagnosticReporterWithContext(
|
|||||||
sourceElement?.let { report(factory.on(it, a1, a2, positioningStrategy), this) }
|
sourceElement?.let { report(factory.on(it, a1, a2, positioningStrategy), this) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <A : Any> reportAndCommit(factory: KtDiagnosticFactory1<A>, a: A) {
|
||||||
|
sourceElement?.let {
|
||||||
|
reportOn(it, factory, a, this)
|
||||||
|
checkAndCommitReportsOn(it, this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean {
|
override fun equals(other: Any?): Boolean {
|
||||||
if (this === other) return true
|
if (this === other) return true
|
||||||
if (other !is DiagnosticContextImpl) return false
|
if (other !is DiagnosticContextImpl) return false
|
||||||
|
|||||||
+1
-1
@@ -147,7 +147,7 @@ class JvmSignatureClashDetector(
|
|||||||
irDeclarations.mapNotNullTo(LinkedHashSet()) { irDeclaration ->
|
irDeclarations.mapNotNullTo(LinkedHashSet()) { irDeclaration ->
|
||||||
classCodegen.context.ktDiagnosticReporter.atFirstValidFrom(irDeclaration, classCodegen.irClass, containingIrFile = irDeclaration.file)
|
classCodegen.context.ktDiagnosticReporter.atFirstValidFrom(irDeclaration, classCodegen.irClass, containingIrFile = irDeclaration.file)
|
||||||
}.forEach {
|
}.forEach {
|
||||||
it.report(diagnosticFactory1, conflictingJvmDeclarationsData)
|
it.reportAndCommit(diagnosticFactory1, conflictingJvmDeclarationsData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/conflictingJvmDeclarations.kt
|
||||||
|
-Xuse-k2
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
class Foo {
|
||||||
|
val x: Int
|
||||||
|
get() = 42
|
||||||
|
|
||||||
|
fun getX() = 42
|
||||||
|
|
||||||
|
@JvmName("getX")
|
||||||
|
fun getY() = 42
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
warning: ATTENTION!
|
||||||
|
This build uses experimental K2 compiler:
|
||||||
|
-Xuse-k2
|
||||||
|
compiler/testData/cli/jvm/conflictingJvmDeclarations.kt:2:5: error: platform declaration clash: The following declarations have the same JVM signature (getX()I):
|
||||||
|
fun `<get-x>`(): Int defined in Foo
|
||||||
|
fun getX(): Int defined in Foo
|
||||||
|
fun getY(): Int defined in Foo
|
||||||
|
val x: Int
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/conflictingJvmDeclarations.kt:5:5: error: platform declaration clash: The following declarations have the same JVM signature (getX()I):
|
||||||
|
fun `<get-x>`(): Int defined in Foo
|
||||||
|
fun getX(): Int defined in Foo
|
||||||
|
fun getY(): Int defined in Foo
|
||||||
|
fun getX() = 42
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/conflictingJvmDeclarations.kt:7:5: error: platform declaration clash: The following declarations have the same JVM signature (getX()I):
|
||||||
|
fun `<get-x>`(): Int defined in Foo
|
||||||
|
fun getX(): Int defined in Foo
|
||||||
|
fun getY(): Int defined in Foo
|
||||||
|
@JvmName("getX")
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
@@ -237,6 +237,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
runTest("compiler/testData/cli/jvm/compatqualWrong.args");
|
runTest("compiler/testData/cli/jvm/compatqualWrong.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("conflictingJvmDeclarations.args")
|
||||||
|
public void testConflictingJvmDeclarations() throws Exception {
|
||||||
|
runTest("compiler/testData/cli/jvm/conflictingJvmDeclarations.args");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("conflictingOverloads.args")
|
@TestMetadata("conflictingOverloads.args")
|
||||||
public void testConflictingOverloads() throws Exception {
|
public void testConflictingOverloads() throws Exception {
|
||||||
runTest("compiler/testData/cli/jvm/conflictingOverloads.args");
|
runTest("compiler/testData/cli/jvm/conflictingOverloads.args");
|
||||||
|
|||||||
Reference in New Issue
Block a user