[klib] Make CONFLICTING_KLIB_SIGNATURES_DATA diagnostic more precise
Show what kind of declarations exactly are clashing: functions, properties, or fields. This is so that diagnostics about clashing properties and fields are distinguishable from one another, since properties and fields are rendered the same way in those diagnostics:
This commit is contained in:
committed by
Space Team
parent
d80a67652f
commit
03ca64c954
+4
-1
@@ -72,11 +72,14 @@ object CommonRenderers {
|
||||
declarationRenderer: DiagnosticParameterRenderer<Declaration>,
|
||||
renderSignature: StringBuilder.(Data) -> Unit,
|
||||
declarations: (Data) -> Collection<Declaration>,
|
||||
declarationKind: (Data) -> String = { "declarations" },
|
||||
) = Renderer<Data> { data ->
|
||||
val sortedDeclarations = declarations(data).sortedWith(sortUsing)
|
||||
val renderingContext = RenderingContext.Impl(sortedDeclarations)
|
||||
buildString {
|
||||
append("The following declarations have the same ")
|
||||
append("The following ")
|
||||
append(declarationKind(data))
|
||||
append(" have the same ")
|
||||
append(signatureKind)
|
||||
append(" signature (")
|
||||
renderSignature(data)
|
||||
|
||||
+11
@@ -15,6 +15,9 @@ import org.jetbrains.kotlin.diagnostics.rendering.CommonRenderers
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.Renderer
|
||||
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrField
|
||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor
|
||||
import org.jetbrains.kotlin.ir.util.render
|
||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
||||
@@ -48,5 +51,13 @@ internal object SerializationDiagnosticRenderers {
|
||||
},
|
||||
renderSignature = { append(it.signature.render()) },
|
||||
declarations = { it.declarations.map(IrDeclaration::toIrBasedDescriptor) },
|
||||
declarationKind = { data ->
|
||||
when {
|
||||
data.declarations.all { it is IrSimpleFunction } -> "functions"
|
||||
data.declarations.all { it is IrProperty } -> "properties"
|
||||
data.declarations.all { it is IrField } -> "fields"
|
||||
else -> "declarations"
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
+13
-13
@@ -1,60 +1,60 @@
|
||||
/foo.kt:13:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
|
||||
/foo.kt:13:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
|
||||
fun foo(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/foo.kt:16:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
/foo.kt:16:1: error: Platform declaration clash: The following properties have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/foo.kt:16:1: error: Platform declaration clash: The following declarations have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
/foo.kt:16:1: error: Platform declaration clash: The following fields have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/foo.kt:16:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
/foo.kt:16:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:21:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
|
||||
/main.kt:21:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
|
||||
fun foo(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:24:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
|
||||
/main.kt:24:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/foo|foo(){}[0]):
|
||||
fun foo(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:26:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
/main.kt:26:1: error: Platform declaration clash: The following properties have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:26:1: error: Platform declaration clash: The following declarations have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
/main.kt:26:1: error: Platform declaration clash: The following fields have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:26:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
/main.kt:26:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:29:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
/main.kt:29:1: error: Platform declaration clash: The following properties have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:31:5: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
/main.kt:31:5: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:44:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
|
||||
/main.kt:44:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
|
||||
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
/main.kt:47:1: error: Platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
|
||||
/main.kt:47:1: error: Platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/bar|bar(){}[0]):
|
||||
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun bar(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
+4
-4
@@ -1,16 +1,16 @@
|
||||
Module: common
|
||||
/common.kt:7:1: error: Platform declaration clash: The following declarations have the same IR signature (/foo|foo(){}[0]):
|
||||
/common.kt:7:1: error: Platform declaration clash: The following functions have the same IR signature (/foo|foo(){}[0]):
|
||||
fun foo(): kotlin.Int defined in root package
|
||||
fun foo(): kotlin.String defined in root package
|
||||
|
||||
/common.kt:10:1: error: Platform declaration clash: The following declarations have the same IR signature (/bar|bar(B){}[0]):
|
||||
/common.kt:10:1: error: Platform declaration clash: The following functions have the same IR signature (/bar|bar(B){}[0]):
|
||||
fun bar(x: B): kotlin.Int defined in root package
|
||||
fun bar(x: B): kotlin.Int defined in root package
|
||||
Module: platform
|
||||
/platform.kt:14:1: error: Platform declaration clash: The following declarations have the same IR signature (/foo|foo(){}[0]):
|
||||
/platform.kt:14:1: error: Platform declaration clash: The following functions have the same IR signature (/foo|foo(){}[0]):
|
||||
fun foo(): kotlin.Int defined in root package
|
||||
fun foo(): kotlin.String defined in root package
|
||||
|
||||
/platform.kt:18:1: error: Platform declaration clash: The following declarations have the same IR signature (/bar|bar(B){}[0]):
|
||||
/platform.kt:18:1: error: Platform declaration clash: The following functions have the same IR signature (/bar|bar(B){}[0]):
|
||||
fun bar(x: B): kotlin.Int defined in root package
|
||||
fun bar(x: B): kotlin.Int defined in root package
|
||||
|
||||
+10
-10
@@ -1,54 +1,54 @@
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:4:5: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/A.foo|foo(){}[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:4:5: error: platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/A.foo|foo(){}[0]):
|
||||
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics.A
|
||||
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics.A
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:7:5: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/A.foo|foo(){}[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:7:5: error: platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/A.foo|foo(){}[0]):
|
||||
fun foo(): kotlin.String defined in com.example.klib.serialization.diagnostics.A
|
||||
fun foo(): kotlin.Int defined in com.example.klib.serialization.diagnostics.A
|
||||
fun foo(): Int = 0
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:10:1: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:10:1: error: platform declaration clash: The following properties have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: Long = 0L
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:10:1: error: platform declaration clash: The following declarations have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:10:1: error: platform declaration clash: The following fields have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: Long = 0L
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:10:1: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:10:1: error: platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: Long = 0L
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:15:1: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:15:1: error: platform declaration clash: The following properties have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:15:1: error: platform declaration clash: The following declarations have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:15:1: error: platform declaration clash: The following fields have the same IR signature ([ com.example.klib.serialization.diagnostics/myVal|{}myVal[0] <- Local[<BF>|FIELD PROPERTY_BACKING_FIELD name:myVal type:kotlin.Long visibility:private [static]] ]):
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:15:1: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:15:1: error: platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:18:1: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:18:1: error: platform declaration clash: The following properties have the same IR signature (com.example.klib.serialization.diagnostics/myVal|{}myVal[0]):
|
||||
val myVal: kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
var myVal: kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
@Deprecated("", level = DeprecationLevel.HIDDEN)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:20:5: error: platform declaration clash: The following declarations have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
native/native.tests/testData/compilerOutput/SignatureClashDiagnostics/main.kt:20:5: error: platform declaration clash: The following functions have the same IR signature (com.example.klib.serialization.diagnostics/myVal.<get-myVal>|<get-myVal>(){}[0]):
|
||||
fun `<get-myVal>`(): kotlin.Int defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.Long defined in com.example.klib.serialization.diagnostics
|
||||
fun `<get-myVal>`(): kotlin.String defined in com.example.klib.serialization.diagnostics
|
||||
|
||||
Reference in New Issue
Block a user