diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index 0411b38411b..16686f197b3 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -23456,6 +23456,52 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/override/derivedClasses") + @TestDataPath("$PROJECT_ROOT") + public class DerivedClasses { + @Test + public void testAllFilesPresentInDerivedClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/override/derivedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("Constructor.kt") + public void testConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt"); + } + + @Test + @TestMetadata("DelegatedConstructor.kt") + public void testDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt"); + } + + @Test + @TestMetadata("EnumValues.kt") + public void testEnumValues() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt"); + } + + @Test + @TestMetadata("Instance.kt") + public void testInstance() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt"); + } + + @Test + @TestMetadata("StaticFieldFromJava.kt") + public void testStaticFieldFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt"); + } + + @Test + @TestMetadata("StaticMethodFromJava.kt") + public void testStaticMethodFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index d9624a5cae2..451cf006847 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -23462,6 +23462,52 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/override/derivedClasses") + @TestDataPath("$PROJECT_ROOT") + public class DerivedClasses { + @Test + public void testAllFilesPresentInDerivedClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/override/derivedClasses"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("Constructor.kt") + public void testConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt"); + } + + @Test + @TestMetadata("DelegatedConstructor.kt") + public void testDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt"); + } + + @Test + @TestMetadata("EnumValues.kt") + public void testEnumValues() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt"); + } + + @Test + @TestMetadata("Instance.kt") + public void testInstance() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt"); + } + + @Test + @TestMetadata("StaticFieldFromJava.kt") + public void testStaticFieldFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt"); + } + + @Test + @TestMetadata("StaticMethodFromJava.kt") + public void testStaticMethodFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index efa76a75c9a..6e4ea0fd378 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -23456,6 +23456,52 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/override/derivedClasses") + @TestDataPath("$PROJECT_ROOT") + public class DerivedClasses { + @Test + public void testAllFilesPresentInDerivedClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/override/derivedClasses"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("Constructor.kt") + public void testConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt"); + } + + @Test + @TestMetadata("DelegatedConstructor.kt") + public void testDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt"); + } + + @Test + @TestMetadata("EnumValues.kt") + public void testEnumValues() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt"); + } + + @Test + @TestMetadata("Instance.kt") + public void testInstance() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt"); + } + + @Test + @TestMetadata("StaticFieldFromJava.kt") + public void testStaticFieldFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt"); + } + + @Test + @TestMetadata("StaticMethodFromJava.kt") + public void testStaticMethodFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory.kt b/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory.kt index 1be11d3eafb..feb2290770d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory.kt @@ -8,7 +8,7 @@ package org.jetbrains.kotlin.checkers.diagnostics.factories import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.diagnostics.Diagnostic -import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory @@ -16,7 +16,7 @@ interface DebugInfoDiagnosticFactory { val withExplicitDefinitionOnly: Boolean fun createDiagnostic( - expression: KtExpression, + element: KtElement, bindingContext: BindingContext, dataFlowValueFactory: DataFlowValueFactory?, languageVersionSettings: LanguageVersionSettings?, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory0.kt b/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory0.kt index bf25bf84035..f340744ab2c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory0.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory0.kt @@ -13,7 +13,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0 import org.jetbrains.kotlin.diagnostics.PositioningStrategies import org.jetbrains.kotlin.diagnostics.Severity -import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory @@ -25,13 +25,13 @@ class DebugInfoDiagnosticFactory0 private constructor( override val withExplicitDefinitionOnly: Boolean = false override fun createDiagnostic( - expression: KtExpression, + element: KtElement, bindingContext: BindingContext, dataFlowValueFactory: DataFlowValueFactory?, languageVersionSettings: LanguageVersionSettings?, moduleDescriptor: ModuleDescriptorImpl? ): Diagnostic { - return DebugInfoDiagnostic(expression, this) + return DebugInfoDiagnostic(element, this) } override val name: String diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory1.kt b/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory1.kt index fd12864470e..e80bd0b4040 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory1.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/diagnostics/factories/DebugInfoDiagnosticFactory1.kt @@ -13,9 +13,16 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1 import org.jetbrains.kotlin.diagnostics.PositioningStrategies import org.jetbrains.kotlin.diagnostics.Severity import org.jetbrains.kotlin.diagnostics.rendering.Renderers -import org.jetbrains.kotlin.psi.KtExpression +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.psi.KtElement import org.jetbrains.kotlin.resolve.BindingContext import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory +import org.jetbrains.kotlin.resolve.calls.util.getCall +import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameOrNull +import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe class DebugInfoDiagnosticFactory1 : DiagnosticFactory1, DebugInfoDiagnosticFactory { @@ -27,7 +34,7 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1, override val withExplicitDefinitionOnly: Boolean override fun createDiagnostic( - expression: KtExpression, + element: KtElement, bindingContext: BindingContext, dataFlowValueFactory: DataFlowValueFactory?, languageVersionSettings: LanguageVersionSettings?, @@ -35,18 +42,32 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1, ) = when (privateName) { EXPRESSION_TYPE.privateName -> { val (type, dataFlowTypes) = CheckerTestUtil.getTypeInfo( - expression, + element, bindingContext, dataFlowValueFactory, languageVersionSettings, moduleDescriptor ) - this.on(expression, Renderers.renderExpressionType(type, dataFlowTypes)) + this.on(element, Renderers.renderExpressionType(type, dataFlowTypes)) } CALL.privateName -> { - val (fqName, typeCall) = CheckerTestUtil.getCallDebugInfo(expression, bindingContext) - this.on(expression, Renderers.renderCallInfo(fqName, typeCall)) + val (fqName, typeCall) = CheckerTestUtil.getCallDebugInfo(element, bindingContext) + this.on(element, Renderers.renderCallInfo(fqName, typeCall)) + } + CALLABLE_OWNER.privateName -> { + val resolvedCall = element.getCall(bindingContext)?.getResolvedCall(bindingContext) + if (resolvedCall != null) { + val callableDescriptor = resolvedCall.resultingDescriptor + val text = renderCallableOwner( + callableDescriptor.fqNameSafe, + callableDescriptor.containingDeclaration.fqNameOrNull(), + isImplicit = false + ) + this.on(element, text) + } else { + this.on(element, "") + } } else -> throw NotImplementedError("Creation diagnostic '$name' isn't supported.") } @@ -70,6 +91,11 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1, Severity.INFO, true ) + val CALLABLE_OWNER = create( + "CALLABLE_OWNER", + Severity.INFO, + true + ) val CALL = create( "CALL", Severity.INFO, @@ -83,5 +109,20 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1, fun create(name: String, severity: Severity, withExplicitDefinitionOnly: Boolean): DebugInfoDiagnosticFactory1 { return DebugInfoDiagnosticFactory1(name, severity, withExplicitDefinitionOnly) } + + fun renderCallableOwner(callableId: CallableId, ownerId: ClassId?, isExplicit: Boolean): String { + return renderCallableOwner(callableId.asFqNameForDebugInfo(), ownerId?.asSingleFqName(), isExplicit) + } + + private fun renderCallableOwner(callableFqName: FqName, ownerFqName: FqName?, isImplicit: Boolean): String { + return buildString { + append(callableFqName.asString()) + append(" in ") + if (isImplicit) { + append("implicit ") + } + append(ownerFqName?.asString() ?: "") + } + } } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/checkers/utils/CheckerTestUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/checkers/utils/CheckerTestUtil.kt index ab1517ef062..0de61cccc48 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/checkers/utils/CheckerTestUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/checkers/utils/CheckerTestUtil.kt @@ -27,9 +27,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.isCommon import org.jetbrains.kotlin.platform.oldFashionedDescription -import org.jetbrains.kotlin.psi.KtCallableDeclaration -import org.jetbrains.kotlin.psi.KtExpression -import org.jetbrains.kotlin.psi.KtReferenceExpression +import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.resolve.AnalyzingUtils @@ -177,15 +175,17 @@ object CheckerTestUtil { //noinspection unchecked val factoryListForDiagnosticsOnExpression = listOf( - BindingContext.EXPRESSION_TYPE_INFO to DebugInfoDiagnosticFactory1.EXPRESSION_TYPE, - BindingContext.SMARTCAST to DebugInfoDiagnosticFactory0.SMARTCAST, - BindingContext.IMPLICIT_RECEIVER_SMARTCAST to DebugInfoDiagnosticFactory0.IMPLICIT_RECEIVER_SMARTCAST, - BindingContext.SMARTCAST_NULL to DebugInfoDiagnosticFactory0.CONSTANT, - BindingContext.LEAKING_THIS to DebugInfoDiagnosticFactory0.LEAKING_THIS, - BindingContext.IMPLICIT_EXHAUSTIVE_WHEN to DebugInfoDiagnosticFactory0.IMPLICIT_EXHAUSTIVE + BindingContext.EXPRESSION_TYPE_INFO to listOf(DebugInfoDiagnosticFactory1.EXPRESSION_TYPE), + BindingContext.SMARTCAST to listOf(DebugInfoDiagnosticFactory0.SMARTCAST), + BindingContext.IMPLICIT_RECEIVER_SMARTCAST to listOf(DebugInfoDiagnosticFactory0.IMPLICIT_RECEIVER_SMARTCAST), + BindingContext.SMARTCAST_NULL to listOf(DebugInfoDiagnosticFactory0.CONSTANT), + BindingContext.LEAKING_THIS to listOf(DebugInfoDiagnosticFactory0.LEAKING_THIS), + BindingContext.IMPLICIT_EXHAUSTIVE_WHEN to listOf(DebugInfoDiagnosticFactory0.IMPLICIT_EXHAUSTIVE) ) - val factoryListForDiagnosticsOnCall = listOf(BindingContext.RESOLVED_CALL to DebugInfoDiagnosticFactory1.CALL) + val factoryListForDiagnosticsOnCall = listOf( + BindingContext.RESOLVED_CALL to listOf(DebugInfoDiagnosticFactory1.CALL, DebugInfoDiagnosticFactory1.CALLABLE_OWNER) + ) renderDiagnosticsByFactoryList( factoryListForDiagnosticsOnExpression, root, bindingContext, configuration, @@ -195,13 +195,13 @@ object CheckerTestUtil { renderDiagnosticsByFactoryList( factoryListForDiagnosticsOnCall, root, bindingContext, configuration, dataFlowValueFactory, moduleDescriptor, diagnosedRanges, debugAnnotations - ) { it.callElement as? KtExpression } + ) { it.callElement } return debugAnnotations } private fun renderDiagnosticsByFactoryList( - factoryList: List, DebugInfoDiagnosticFactory>>, + factoryList: List, List>>, root: PsiElement, bindingContext: BindingContext, configuration: DiagnosticsRenderingConfiguration, @@ -209,23 +209,25 @@ object CheckerTestUtil { moduleDescriptor: ModuleDescriptorImpl?, diagnosedRanges: Map>?, debugAnnotations: MutableList, - toExpression: (T) -> KtExpression? = { it as? KtExpression } + elementProvider: (T) -> KtElement? = { it as? KtElement } ) { - for ((context, factory) in factoryList) { + for ((context, factories) in factoryList) { for ((element, _) in bindingContext.getSliceContents(context)) { - renderDiagnostics( - factory, - toExpression(element) ?: continue, - root, bindingContext, configuration, dataFlowValueFactory, moduleDescriptor, diagnosedRanges, - debugAnnotations - ) + for (factory in factories) { + renderDiagnostics( + factory, + elementProvider(element) ?: continue, + root, bindingContext, configuration, dataFlowValueFactory, moduleDescriptor, diagnosedRanges, + debugAnnotations + ) + } } } } private fun renderDiagnostics( factory: DebugInfoDiagnosticFactory, - expression: KtExpression, + element: KtElement, root: PsiElement, bindingContext: BindingContext, configuration: DiagnosticsRenderingConfiguration, @@ -237,11 +239,11 @@ object CheckerTestUtil { if (factory !is DiagnosticFactory<*>) return val needRender = !factory.withExplicitDefinitionOnly - || diagnosedRanges?.get(expression.startOffset..expression.endOffset)?.contains(factory.name) == true + || diagnosedRanges?.get(element.startOffset..element.endOffset)?.contains(factory.name) == true - if (PsiTreeUtil.isAncestor(root, expression, false) && needRender) { + if (PsiTreeUtil.isAncestor(root, element, false) && needRender) { val diagnostic = factory.createDiagnostic( - expression, + element, bindingContext, dataFlowValueFactory, configuration.languageVersionSettings, diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.fir.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.fir.kt new file mode 100644 index 00000000000..4f039745aac --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.fir.kt @@ -0,0 +1,7 @@ +open class Foo(val item: T) + +class Bar(str: String) : Foo(str) + +fun usage(bar: Bar) { + Bar("bar") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt new file mode 100644 index 00000000000..a2fa3055570 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt @@ -0,0 +1,7 @@ +open class Foo(val item: T) + +class Bar(str: String) : Foo(str) + +fun usage(bar: Bar) { + in Bar")!>Bar("bar") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.txt b/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.txt new file mode 100644 index 00000000000..8463ccac0ff --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.txt @@ -0,0 +1,19 @@ +package + +public fun usage(/*0*/ bar: Bar): kotlin.Unit + +public final class Bar : Foo { + public constructor Bar(/*0*/ str: kotlin.String) + public final override /*1*/ /*fake_override*/ val item: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Foo { + public constructor Foo(/*0*/ item: T) + public final val item: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.fir.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.fir.kt new file mode 100644 index 00000000000..da4162ac56a --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.fir.kt @@ -0,0 +1,3 @@ +open class Foo(val item: T) + +class Bar(str: String) : Foo(str) diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt new file mode 100644 index 00000000000..656d2cebce4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt @@ -0,0 +1,3 @@ +open class Foo(val item: T) + +class Bar(str: String) : in Foo")!>Foo(str) diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.txt b/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.txt new file mode 100644 index 00000000000..250d8f5bb52 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.txt @@ -0,0 +1,17 @@ +package + +public final class Bar : Foo { + public constructor Bar(/*0*/ str: kotlin.String) + public final override /*1*/ /*fake_override*/ val item: kotlin.String + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Foo { + public constructor Foo(/*0*/ item: T) + public final val item: T + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.fir.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.fir.kt new file mode 100644 index 00000000000..ea48b2e7922 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.fir.kt @@ -0,0 +1,7 @@ +enum class Direction { + NORTH, EAST, SOUTH, WEST +} + +fun usage() { + Direction.values() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt new file mode 100644 index 00000000000..4ce63ac1af4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt @@ -0,0 +1,7 @@ +enum class Direction { + NORTH, EAST, SOUTH, WEST +} + +fun usage() { + Direction.values() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.txt b/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.txt new file mode 100644 index 00000000000..7bf6eb34bf3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.txt @@ -0,0 +1,28 @@ +package + +public fun usage(): kotlin.Unit + +public final enum class Direction : kotlin.Enum { + enum entry NORTH + + enum entry EAST + + enum entry SOUTH + + enum entry WEST + + private constructor Direction() + @kotlin.internal.IntrinsicConstEvaluation public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: Direction): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): Direction + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.fir.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.fir.kt new file mode 100644 index 00000000000..c5efed0ed00 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.fir.kt @@ -0,0 +1,9 @@ +interface Foo { + fun foo() +} + +interface Bar : Foo + +fun usage(bar: Bar) { + bar.foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt new file mode 100644 index 00000000000..9956f77d048 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt @@ -0,0 +1,9 @@ +interface Foo { + fun foo() +} + +interface Bar : Foo + +fun usage(bar: Bar) { + bar.foo() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.txt b/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.txt new file mode 100644 index 00000000000..d8103527671 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/Instance.txt @@ -0,0 +1,17 @@ +package + +public fun usage(/*0*/ bar: Bar): kotlin.Unit + +public interface Bar : Foo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Foo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.fir.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.fir.kt new file mode 100644 index 00000000000..88ccbc78ca9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.fir.kt @@ -0,0 +1,18 @@ +// MODULE: lib +// FILE: test/J.java +package test; + +interface I { + // Not a String to avoid constant inlining + public static String[] OK = new String[]{"OK"}; +} + +public class J implements I {} + +// MODULE: main(lib) +// FILE: k.kt +import test.J + +fun test() { + J.OK +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt new file mode 100644 index 00000000000..85f8d94e4b4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt @@ -0,0 +1,18 @@ +// MODULE: lib +// FILE: test/J.java +package test; + +interface I { + // Not a String to avoid constant inlining + public static String[] OK = new String[]{"OK"}; +} + +public class J implements I {} + +// MODULE: main(lib) +// FILE: k.kt +import test.J + +fun test() { + J.OK +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.txt b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.txt new file mode 100644 index 00000000000..339b31fad82 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.txt @@ -0,0 +1,30 @@ +// -- Module: -- +package + +package test { + + public/*package*/ interface I { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final val OK: kotlin.Array<(out) kotlin.String!>! + } + + public open class J : test.I { + public constructor J() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final override /*1*/ /*fake_override*/ val OK: kotlin.Array<(out) kotlin.String!>! + } +} + +// -- Module:
-- +package + +public fun test(): kotlin.Unit + diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.fir.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.fir.kt new file mode 100644 index 00000000000..9f8e99bf505 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.fir.kt @@ -0,0 +1,19 @@ +// MODULE: lib +// FILE: test/J.java +package test; + +class Foo { + public static String getValue(K key) { + return null; + } +} + +public class Bar extends Foo {} + +// MODULE: main(lib) +// FILE: k.kt +import test.Bar + +fun test() { + Bar.getValue("bar") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt new file mode 100644 index 00000000000..e9e845bae93 --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt @@ -0,0 +1,19 @@ +// MODULE: lib +// FILE: test/J.java +package test; + +class Foo { + public static String getValue(K key) { + return null; + } +} + +public class Bar extends Foo {} + +// MODULE: main(lib) +// FILE: k.kt +import test.Bar + +fun test() { + Bar.getValue("bar") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.txt b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.txt new file mode 100644 index 00000000000..281de6d05fd --- /dev/null +++ b/compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.txt @@ -0,0 +1,30 @@ +// -- Module: -- +package + +package test { + + public open class Bar : test.Foo { + public constructor Bar() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open override /*1*/ /*fake_override*/ fun getValue(/*0*/ key: K!): kotlin.String! + } + + public/*package*/ open class Foo { + public/*package*/ constructor Foo() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun getValue(/*0*/ key: K!): kotlin.String! + } +} + +// -- Module:
-- +package + +public fun test(): kotlin.Unit diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index d828e24474c..16a944d8eea 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -23462,6 +23462,52 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/override/derivedClasses") + @TestDataPath("$PROJECT_ROOT") + public class DerivedClasses { + @Test + public void testAllFilesPresentInDerivedClasses() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/override/derivedClasses"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true); + } + + @Test + @TestMetadata("Constructor.kt") + public void testConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Constructor.kt"); + } + + @Test + @TestMetadata("DelegatedConstructor.kt") + public void testDelegatedConstructor() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/DelegatedConstructor.kt"); + } + + @Test + @TestMetadata("EnumValues.kt") + public void testEnumValues() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/EnumValues.kt"); + } + + @Test + @TestMetadata("Instance.kt") + public void testInstance() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/Instance.kt"); + } + + @Test + @TestMetadata("StaticFieldFromJava.kt") + public void testStaticFieldFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticFieldFromJava.kt"); + } + + @Test + @TestMetadata("StaticMethodFromJava.kt") + public void testStaticMethodFromJava() throws Exception { + runTest("compiler/testData/diagnostics/tests/override/derivedClasses/StaticMethodFromJava.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt index d13982e915f..172e1eedacd 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/fir/handlers/FirDiagnosticsHandler.kt @@ -11,17 +11,16 @@ import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFa import org.jetbrains.kotlin.checkers.utils.TypeOfCall import org.jetbrains.kotlin.diagnostics.* import org.jetbrains.kotlin.diagnostics.rendering.Renderers -import org.jetbrains.kotlin.fir.FirElement +import org.jetbrains.kotlin.fir.* import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors +import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirProperty import org.jetbrains.kotlin.fir.expressions.* -import org.jetbrains.kotlin.fir.psi import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference -import org.jetbrains.kotlin.fir.renderForDebugInfo import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol import org.jetbrains.kotlin.fir.symbols.SymbolInternals import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol @@ -156,7 +155,9 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes } override fun visitFunctionCall(functionCall: FirFunctionCall) { - consumer.reportCallDiagnostic(functionCall, functionCall.calleeReference) + val reference = functionCall.calleeReference + consumer.reportCallDiagnostic(functionCall, reference) + consumer.reportContainingClassDiagnostic(functionCall, reference) super.visitFunctionCall(functionCall) } @@ -166,10 +167,27 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes if (selector is FirQualifiedAccess) { val reference = selector.calleeReference as FirNamedReference consumer.reportCallDiagnostic(safeCallExpression, reference) + consumer.reportContainingClassDiagnostic(safeCallExpression, reference) } super.visitSafeCallExpression(safeCallExpression) } + + override fun visitPropertyAccessExpression(propertyAccessExpression: FirPropertyAccessExpression) { + val reference = propertyAccessExpression.calleeReference + if (reference is FirNamedReference) { + consumer.reportContainingClassDiagnostic(propertyAccessExpression, reference) + } + + super.visitPropertyAccessExpression(propertyAccessExpression) + } + + override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall) { + val reference = delegatedConstructorCall.calleeReference as FirNamedReference + consumer.reportContainingClassDiagnostic(delegatedConstructorCall, reference) + + super.visitDelegatedConstructorCall(delegatedConstructorCall) + } }.let(firFile::accept) val codeMetaInfos = result.flatMap { diagnostic -> @@ -208,6 +226,18 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes } } + private fun DebugDiagnosticConsumer.reportContainingClassDiagnostic(element: FirElement, reference: FirNamedReference) { + report(DebugInfoDiagnosticFactory1.CALLABLE_OWNER, element) { + val resolvedSymbol = (reference as? FirResolvedNamedReference)?.resolvedSymbol + val callable = resolvedSymbol?.fir as? FirCallableDeclaration ?: return@report "" + DebugInfoDiagnosticFactory1.renderCallableOwner( + callable.symbol.callableId, + callable.containingClassLookupTag()?.classId, + callable.containingClassForStaticMemberAttr == null + ) + } + } + private fun getTypeOfCall( reference: FirNamedReference, resolvedSymbol: FirBasedSymbol<*>? @@ -253,7 +283,8 @@ private class DebugDiagnosticConsumer( KtRealSourceElementKind, KtFakeSourceElementKind.DesugaredCompoundAssignment, KtFakeSourceElementKind.ReferenceInAtomicQualifiedAccess, - KtFakeSourceElementKind.SmartCastExpression + KtFakeSourceElementKind.SmartCastExpression, + KtFakeSourceElementKind.DelegatingConstructorCall ) } diff --git a/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt b/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt index a17cea4613f..7ec545efef0 100644 --- a/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt +++ b/compiler/tests-common/tests/org/jetbrains/kotlin/fir/AbstractFirDiagnosticTest.kt @@ -14,12 +14,11 @@ import org.jetbrains.kotlin.diagnostics.rendering.Renderers import org.jetbrains.kotlin.fir.analysis.collectors.AbstractDiagnosticCollector import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector import org.jetbrains.kotlin.fir.analysis.diagnostics.* +import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration import org.jetbrains.kotlin.fir.declarations.FirFile import org.jetbrains.kotlin.fir.declarations.FirFunction import org.jetbrains.kotlin.fir.declarations.FirProperty -import org.jetbrains.kotlin.fir.expressions.FirExpression -import org.jetbrains.kotlin.fir.expressions.FirFunctionCall -import org.jetbrains.kotlin.fir.expressions.FirSmartCastExpression +import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.references.FirNamedReference import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference import org.jetbrains.kotlin.fir.renderer.FirRenderer @@ -133,7 +132,7 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { KotlinTestUtils.assertEqualsToFile(file, actualText) } - protected fun collectDebugInfoDiagnostics( + private fun collectDebugInfoDiagnostics( firFile: FirFile, diagnosedRangesToDiagnosticNames: MutableMap> ): List { @@ -154,12 +153,26 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { } override fun visitFunctionCall(functionCall: FirFunctionCall) { - result.addIfNotNull( - createCallDiagnosticIfExpected(functionCall, functionCall.calleeReference, diagnosedRangesToDiagnosticNames) - ) + val reference = functionCall.calleeReference + result.addIfNotNull(createCallDiagnosticIfExpected(functionCall, reference, diagnosedRangesToDiagnosticNames)) + result.addIfNotNull(createDerivedClassDiagnosticIfExpected(functionCall, reference, diagnosedRangesToDiagnosticNames)) super.visitFunctionCall(functionCall) } + + override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall) { + val reference = delegatedConstructorCall.calleeReference as FirNamedReference + result.addIfNotNull( + createDerivedClassDiagnosticIfExpected(delegatedConstructorCall, reference, diagnosedRangesToDiagnosticNames)) + + super.visitDelegatedConstructorCall(delegatedConstructorCall) + } + + override fun visitPropertyAccessExpression(propertyAccessExpression: FirPropertyAccessExpression) { + val reference = propertyAccessExpression.calleeReference as FirNamedReference + result.addIfNotNull( + createDerivedClassDiagnosticIfExpected(propertyAccessExpression, reference, diagnosedRangesToDiagnosticNames)) + } }.let(firFile::accept) return result @@ -185,13 +198,29 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() { element: FirElement, reference: FirNamedReference, diagnosedRangesToDiagnosticNames: MutableMap> - ): KtDiagnosticWithParameters1? = - DebugInfoDiagnosticFactory1.CALL.createDebugInfoDiagnostic(element, diagnosedRangesToDiagnosticNames) { - + ): KtDiagnostic? { + return DebugInfoDiagnosticFactory1.CALL.createDebugInfoDiagnostic(element, diagnosedRangesToDiagnosticNames) { val resolvedSymbol = (reference as? FirResolvedNamedReference)?.resolvedSymbol val fqName = resolvedSymbol?.fqNameUnsafe() Renderers.renderCallInfo(fqName, getTypeOfCall(reference, resolvedSymbol)) } + } + + private fun createDerivedClassDiagnosticIfExpected( + element: FirElement, + reference: FirNamedReference, + diagnosedRangesToDiagnosticNames: MutableMap> + ): KtDiagnostic? { + return DebugInfoDiagnosticFactory1.CALLABLE_OWNER.createDebugInfoDiagnostic(element, diagnosedRangesToDiagnosticNames) { + val resolvedSymbol = (reference as? FirResolvedNamedReference)?.resolvedSymbol + val callable = resolvedSymbol?.fir as? FirCallableDeclaration ?: return@createDebugInfoDiagnostic "" + DebugInfoDiagnosticFactory1.renderCallableOwner( + callable.symbol.callableId, + callable.containingClassLookupTag()?.classId, + callable.containingClassForStaticMemberAttr == null + ) + } + } private fun DebugInfoDiagnosticFactory1.createDebugInfoDiagnostic( element: FirElement,