Add equality to diagnostic context, simplifying deduplication
This commit is contained in:
@@ -193,6 +193,21 @@ sealed class KtFakeSourceElementKind : KtSourceElementKind() {
|
|||||||
sealed class AbstractKtSourceElement {
|
sealed class AbstractKtSourceElement {
|
||||||
abstract val startOffset: Int
|
abstract val startOffset: Int
|
||||||
abstract val endOffset: Int
|
abstract val endOffset: Int
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other !is AbstractKtSourceElement) return false
|
||||||
|
|
||||||
|
if (startOffset != other.startOffset) return false
|
||||||
|
if (endOffset != other.endOffset) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = startOffset
|
||||||
|
result = 31 * result + endOffset
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class KtOffsetsOnlySourceElement(
|
class KtOffsetsOnlySourceElement(
|
||||||
|
|||||||
@@ -67,5 +67,23 @@ open class KtDiagnosticReporterWithContext(
|
|||||||
) {
|
) {
|
||||||
sourceElement?.let { report(factory.on(it, a, positioningStrategy), this) }
|
sourceElement?.let { report(factory.on(it, a, positioningStrategy), this) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other !is DiagnosticContextImpl) return false
|
||||||
|
|
||||||
|
if (sourceElement != other.sourceElement) return false
|
||||||
|
if (containingFilePath != other.containingFilePath) return false
|
||||||
|
if (languageVersionSettings != other.languageVersionSettings) return false
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = sourceElement?.hashCode() ?: 0
|
||||||
|
result = 31 * result + containingFilePath.hashCode()
|
||||||
|
result = 31 * result + languageVersionSettings.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-2
@@ -147,9 +147,10 @@ class JvmSignatureClashDetector(
|
|||||||
irDeclarations: Collection<IrDeclaration>,
|
irDeclarations: Collection<IrDeclaration>,
|
||||||
conflictingJvmDeclarationsData: ConflictingJvmDeclarationsData
|
conflictingJvmDeclarationsData: ConflictingJvmDeclarationsData
|
||||||
) {
|
) {
|
||||||
for (irDeclaration in irDeclarations) {
|
irDeclarations.mapNotNullTo(LinkedHashSet()) { irDeclaration ->
|
||||||
context.ktDiagnosticReporter.atFirstValidFrom(irDeclaration, irClass, containingIrFile = irDeclaration.file)
|
context.ktDiagnosticReporter.atFirstValidFrom(irDeclaration, irClass, containingIrFile = irDeclaration.file)
|
||||||
.report(diagnosticFactory1, conflictingJvmDeclarationsData)
|
}.forEach {
|
||||||
|
it.report(diagnosticFactory1, conflictingJvmDeclarationsData)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user