[FE] Add tests for 'containingClassForStaticMemberAttr'
This commit is contained in:
+46
@@ -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
|
@Nested
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+46
@@ -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
|
@Nested
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+46
@@ -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
|
@Nested
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+2
-2
@@ -8,7 +8,7 @@ package org.jetbrains.kotlin.checkers.diagnostics.factories
|
|||||||
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
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.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
|
|
||||||
@@ -16,7 +16,7 @@ interface DebugInfoDiagnosticFactory {
|
|||||||
val withExplicitDefinitionOnly: Boolean
|
val withExplicitDefinitionOnly: Boolean
|
||||||
|
|
||||||
fun createDiagnostic(
|
fun createDiagnostic(
|
||||||
expression: KtExpression,
|
element: KtElement,
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
dataFlowValueFactory: DataFlowValueFactory?,
|
dataFlowValueFactory: DataFlowValueFactory?,
|
||||||
languageVersionSettings: LanguageVersionSettings?,
|
languageVersionSettings: LanguageVersionSettings?,
|
||||||
|
|||||||
+3
-3
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic
|
|||||||
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
|
import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0
|
||||||
import org.jetbrains.kotlin.diagnostics.PositioningStrategies
|
import org.jetbrains.kotlin.diagnostics.PositioningStrategies
|
||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
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.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
|
|
||||||
@@ -25,13 +25,13 @@ class DebugInfoDiagnosticFactory0 private constructor(
|
|||||||
override val withExplicitDefinitionOnly: Boolean = false
|
override val withExplicitDefinitionOnly: Boolean = false
|
||||||
|
|
||||||
override fun createDiagnostic(
|
override fun createDiagnostic(
|
||||||
expression: KtExpression,
|
element: KtElement,
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
dataFlowValueFactory: DataFlowValueFactory?,
|
dataFlowValueFactory: DataFlowValueFactory?,
|
||||||
languageVersionSettings: LanguageVersionSettings?,
|
languageVersionSettings: LanguageVersionSettings?,
|
||||||
moduleDescriptor: ModuleDescriptorImpl?
|
moduleDescriptor: ModuleDescriptorImpl?
|
||||||
): Diagnostic {
|
): Diagnostic {
|
||||||
return DebugInfoDiagnostic(expression, this)
|
return DebugInfoDiagnostic(element, this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: String
|
override val name: String
|
||||||
|
|||||||
+47
-6
@@ -13,9 +13,16 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1
|
|||||||
import org.jetbrains.kotlin.diagnostics.PositioningStrategies
|
import org.jetbrains.kotlin.diagnostics.PositioningStrategies
|
||||||
import org.jetbrains.kotlin.diagnostics.Severity
|
import org.jetbrains.kotlin.diagnostics.Severity
|
||||||
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
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.BindingContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
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<PsiElement, String>,
|
class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
||||||
DebugInfoDiagnosticFactory {
|
DebugInfoDiagnosticFactory {
|
||||||
@@ -27,7 +34,7 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
|||||||
override val withExplicitDefinitionOnly: Boolean
|
override val withExplicitDefinitionOnly: Boolean
|
||||||
|
|
||||||
override fun createDiagnostic(
|
override fun createDiagnostic(
|
||||||
expression: KtExpression,
|
element: KtElement,
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
dataFlowValueFactory: DataFlowValueFactory?,
|
dataFlowValueFactory: DataFlowValueFactory?,
|
||||||
languageVersionSettings: LanguageVersionSettings?,
|
languageVersionSettings: LanguageVersionSettings?,
|
||||||
@@ -35,18 +42,32 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
|||||||
) = when (privateName) {
|
) = when (privateName) {
|
||||||
EXPRESSION_TYPE.privateName -> {
|
EXPRESSION_TYPE.privateName -> {
|
||||||
val (type, dataFlowTypes) = CheckerTestUtil.getTypeInfo(
|
val (type, dataFlowTypes) = CheckerTestUtil.getTypeInfo(
|
||||||
expression,
|
element,
|
||||||
bindingContext,
|
bindingContext,
|
||||||
dataFlowValueFactory,
|
dataFlowValueFactory,
|
||||||
languageVersionSettings,
|
languageVersionSettings,
|
||||||
moduleDescriptor
|
moduleDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
this.on(expression, Renderers.renderExpressionType(type, dataFlowTypes))
|
this.on(element, Renderers.renderExpressionType(type, dataFlowTypes))
|
||||||
}
|
}
|
||||||
CALL.privateName -> {
|
CALL.privateName -> {
|
||||||
val (fqName, typeCall) = CheckerTestUtil.getCallDebugInfo(expression, bindingContext)
|
val (fqName, typeCall) = CheckerTestUtil.getCallDebugInfo(element, bindingContext)
|
||||||
this.on(expression, Renderers.renderCallInfo(fqName, typeCall))
|
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.")
|
else -> throw NotImplementedError("Creation diagnostic '$name' isn't supported.")
|
||||||
}
|
}
|
||||||
@@ -70,6 +91,11 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
|||||||
Severity.INFO,
|
Severity.INFO,
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
val CALLABLE_OWNER = create(
|
||||||
|
"CALLABLE_OWNER",
|
||||||
|
Severity.INFO,
|
||||||
|
true
|
||||||
|
)
|
||||||
val CALL = create(
|
val CALL = create(
|
||||||
"CALL",
|
"CALL",
|
||||||
Severity.INFO,
|
Severity.INFO,
|
||||||
@@ -83,5 +109,20 @@ class DebugInfoDiagnosticFactory1 : DiagnosticFactory1<PsiElement, String>,
|
|||||||
fun create(name: String, severity: Severity, withExplicitDefinitionOnly: Boolean): DebugInfoDiagnosticFactory1 {
|
fun create(name: String, severity: Severity, withExplicitDefinitionOnly: Boolean): DebugInfoDiagnosticFactory1 {
|
||||||
return DebugInfoDiagnosticFactory1(name, severity, withExplicitDefinitionOnly)
|
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() ?: "<unknown>")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ import org.jetbrains.kotlin.name.FqNameUnsafe
|
|||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
import org.jetbrains.kotlin.platform.isCommon
|
import org.jetbrains.kotlin.platform.isCommon
|
||||||
import org.jetbrains.kotlin.platform.oldFashionedDescription
|
import org.jetbrains.kotlin.platform.oldFashionedDescription
|
||||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
|
||||||
import org.jetbrains.kotlin.psi.KtReferenceExpression
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||||
import org.jetbrains.kotlin.resolve.AnalyzingUtils
|
import org.jetbrains.kotlin.resolve.AnalyzingUtils
|
||||||
@@ -177,15 +175,17 @@ object CheckerTestUtil {
|
|||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
|
|
||||||
val factoryListForDiagnosticsOnExpression = listOf(
|
val factoryListForDiagnosticsOnExpression = listOf(
|
||||||
BindingContext.EXPRESSION_TYPE_INFO to DebugInfoDiagnosticFactory1.EXPRESSION_TYPE,
|
BindingContext.EXPRESSION_TYPE_INFO to listOf(DebugInfoDiagnosticFactory1.EXPRESSION_TYPE),
|
||||||
BindingContext.SMARTCAST to DebugInfoDiagnosticFactory0.SMARTCAST,
|
BindingContext.SMARTCAST to listOf(DebugInfoDiagnosticFactory0.SMARTCAST),
|
||||||
BindingContext.IMPLICIT_RECEIVER_SMARTCAST to DebugInfoDiagnosticFactory0.IMPLICIT_RECEIVER_SMARTCAST,
|
BindingContext.IMPLICIT_RECEIVER_SMARTCAST to listOf(DebugInfoDiagnosticFactory0.IMPLICIT_RECEIVER_SMARTCAST),
|
||||||
BindingContext.SMARTCAST_NULL to DebugInfoDiagnosticFactory0.CONSTANT,
|
BindingContext.SMARTCAST_NULL to listOf(DebugInfoDiagnosticFactory0.CONSTANT),
|
||||||
BindingContext.LEAKING_THIS to DebugInfoDiagnosticFactory0.LEAKING_THIS,
|
BindingContext.LEAKING_THIS to listOf(DebugInfoDiagnosticFactory0.LEAKING_THIS),
|
||||||
BindingContext.IMPLICIT_EXHAUSTIVE_WHEN to DebugInfoDiagnosticFactory0.IMPLICIT_EXHAUSTIVE
|
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(
|
renderDiagnosticsByFactoryList(
|
||||||
factoryListForDiagnosticsOnExpression, root, bindingContext, configuration,
|
factoryListForDiagnosticsOnExpression, root, bindingContext, configuration,
|
||||||
@@ -195,13 +195,13 @@ object CheckerTestUtil {
|
|||||||
renderDiagnosticsByFactoryList(
|
renderDiagnosticsByFactoryList(
|
||||||
factoryListForDiagnosticsOnCall, root, bindingContext, configuration,
|
factoryListForDiagnosticsOnCall, root, bindingContext, configuration,
|
||||||
dataFlowValueFactory, moduleDescriptor, diagnosedRanges, debugAnnotations
|
dataFlowValueFactory, moduleDescriptor, diagnosedRanges, debugAnnotations
|
||||||
) { it.callElement as? KtExpression }
|
) { it.callElement }
|
||||||
|
|
||||||
return debugAnnotations
|
return debugAnnotations
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun <T, K> renderDiagnosticsByFactoryList(
|
private fun <T, K> renderDiagnosticsByFactoryList(
|
||||||
factoryList: List<Pair<WritableSlice<out T, out K>, DebugInfoDiagnosticFactory>>,
|
factoryList: List<Pair<WritableSlice<out T, out K>, List<DebugInfoDiagnosticFactory>>>,
|
||||||
root: PsiElement,
|
root: PsiElement,
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
configuration: DiagnosticsRenderingConfiguration,
|
configuration: DiagnosticsRenderingConfiguration,
|
||||||
@@ -209,23 +209,25 @@ object CheckerTestUtil {
|
|||||||
moduleDescriptor: ModuleDescriptorImpl?,
|
moduleDescriptor: ModuleDescriptorImpl?,
|
||||||
diagnosedRanges: Map<IntRange, MutableSet<String>>?,
|
diagnosedRanges: Map<IntRange, MutableSet<String>>?,
|
||||||
debugAnnotations: MutableList<ActualDiagnostic>,
|
debugAnnotations: MutableList<ActualDiagnostic>,
|
||||||
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)) {
|
for ((element, _) in bindingContext.getSliceContents(context)) {
|
||||||
renderDiagnostics(
|
for (factory in factories) {
|
||||||
factory,
|
renderDiagnostics(
|
||||||
toExpression(element) ?: continue,
|
factory,
|
||||||
root, bindingContext, configuration, dataFlowValueFactory, moduleDescriptor, diagnosedRanges,
|
elementProvider(element) ?: continue,
|
||||||
debugAnnotations
|
root, bindingContext, configuration, dataFlowValueFactory, moduleDescriptor, diagnosedRanges,
|
||||||
)
|
debugAnnotations
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderDiagnostics(
|
private fun renderDiagnostics(
|
||||||
factory: DebugInfoDiagnosticFactory,
|
factory: DebugInfoDiagnosticFactory,
|
||||||
expression: KtExpression,
|
element: KtElement,
|
||||||
root: PsiElement,
|
root: PsiElement,
|
||||||
bindingContext: BindingContext,
|
bindingContext: BindingContext,
|
||||||
configuration: DiagnosticsRenderingConfiguration,
|
configuration: DiagnosticsRenderingConfiguration,
|
||||||
@@ -237,11 +239,11 @@ object CheckerTestUtil {
|
|||||||
if (factory !is DiagnosticFactory<*>) return
|
if (factory !is DiagnosticFactory<*>) return
|
||||||
|
|
||||||
val needRender = !factory.withExplicitDefinitionOnly
|
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(
|
val diagnostic = factory.createDiagnostic(
|
||||||
expression,
|
element,
|
||||||
bindingContext,
|
bindingContext,
|
||||||
dataFlowValueFactory,
|
dataFlowValueFactory,
|
||||||
configuration.languageVersionSettings,
|
configuration.languageVersionSettings,
|
||||||
|
|||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
open class Foo<T>(val item: T)
|
||||||
|
|
||||||
|
class Bar(str: String) : Foo<String>(str)
|
||||||
|
|
||||||
|
fun usage(bar: Bar) {
|
||||||
|
<!DEBUG_INFO_CALLABLE_OWNER("Bar.Bar in Bar")!>Bar("bar")<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
open class Foo<T>(val item: T)
|
||||||
|
|
||||||
|
class Bar(str: String) : Foo<String>(str)
|
||||||
|
|
||||||
|
fun usage(bar: Bar) {
|
||||||
|
<!DEBUG_INFO_CALLABLE_OWNER("Bar.<init> in Bar")!>Bar("bar")<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun usage(/*0*/ bar: Bar): kotlin.Unit
|
||||||
|
|
||||||
|
public final class Bar : Foo<kotlin.String> {
|
||||||
|
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</*0*/ T> {
|
||||||
|
public constructor Foo</*0*/ T>(/*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
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
open class Foo<T>(val item: T)
|
||||||
|
|
||||||
|
class Bar(str: String) : <!DEBUG_INFO_CALLABLE_OWNER("Foo.Foo in Bar")!>Foo<String>(str)<!>
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
open class Foo<T>(val item: T)
|
||||||
|
|
||||||
|
class Bar(str: String) : <!DEBUG_INFO_CALLABLE_OWNER("Foo.<init> in Foo")!>Foo<String>(str)<!>
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public final class Bar : Foo<kotlin.String> {
|
||||||
|
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</*0*/ T> {
|
||||||
|
public constructor Foo</*0*/ T>(/*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
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
enum class Direction {
|
||||||
|
NORTH, EAST, SOUTH, WEST
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
<!DEBUG_INFO_CALLABLE_OWNER("Direction.values in Direction")!>Direction.values()<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
enum class Direction {
|
||||||
|
NORTH, EAST, SOUTH, WEST
|
||||||
|
}
|
||||||
|
|
||||||
|
fun usage() {
|
||||||
|
Direction.<!DEBUG_INFO_CALLABLE_OWNER("Direction.values in Direction")!>values()<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun usage(): kotlin.Unit
|
||||||
|
|
||||||
|
public final enum class Direction : kotlin.Enum<Direction> {
|
||||||
|
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<Direction!>!
|
||||||
|
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<Direction>
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface Foo<T> {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Bar : Foo<String>
|
||||||
|
|
||||||
|
fun usage(bar: Bar) {
|
||||||
|
<!DEBUG_INFO_CALLABLE_OWNER("Bar.foo in implicit Bar")!>bar.foo()<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
interface Foo<T> {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Bar : Foo<String>
|
||||||
|
|
||||||
|
fun usage(bar: Bar) {
|
||||||
|
bar.<!DEBUG_INFO_CALLABLE_OWNER("Bar.foo in Bar")!>foo()<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
public fun usage(/*0*/ bar: Bar): kotlin.Unit
|
||||||
|
|
||||||
|
public interface Bar : Foo<kotlin.String> {
|
||||||
|
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</*0*/ T> {
|
||||||
|
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
|
||||||
|
}
|
||||||
+18
@@ -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() {
|
||||||
|
<!DEBUG_INFO_CALLABLE_OWNER("test.I.OK in test.I")!>J.OK<!>
|
||||||
|
}
|
||||||
+18
@@ -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.<!DEBUG_INFO_CALLABLE_OWNER("test.J.OK in test.J")!>OK<!>
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
// -- Module: <lib> --
|
||||||
|
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: <main> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
|
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// MODULE: lib
|
||||||
|
// FILE: test/J.java
|
||||||
|
package test;
|
||||||
|
|
||||||
|
class Foo<T> {
|
||||||
|
public static <K> String getValue(K key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Bar extends Foo<String> {}
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: k.kt
|
||||||
|
import test.Bar
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
<!DEBUG_INFO_CALLABLE_OWNER("test.Foo.getValue in test.Foo")!>Bar.getValue("bar")<!>
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
// MODULE: lib
|
||||||
|
// FILE: test/J.java
|
||||||
|
package test;
|
||||||
|
|
||||||
|
class Foo<T> {
|
||||||
|
public static <K> String getValue(K key) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Bar extends Foo<String> {}
|
||||||
|
|
||||||
|
// MODULE: main(lib)
|
||||||
|
// FILE: k.kt
|
||||||
|
import test.Bar
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
Bar.<!DEBUG_INFO_CALLABLE_OWNER("test.Bar.getValue in test.Bar")!>getValue("bar")<!>
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
// -- Module: <lib> --
|
||||||
|
package
|
||||||
|
|
||||||
|
package test {
|
||||||
|
|
||||||
|
public open class Bar : test.Foo<kotlin.String!> {
|
||||||
|
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 </*0*/ K : kotlin.Any!> getValue(/*0*/ key: K!): kotlin.String!
|
||||||
|
}
|
||||||
|
|
||||||
|
public/*package*/ open class Foo</*0*/ T : kotlin.Any!> {
|
||||||
|
public/*package*/ constructor Foo</*0*/ T : kotlin.Any!>()
|
||||||
|
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 </*0*/ K : kotlin.Any!> getValue(/*0*/ key: K!): kotlin.String!
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -- Module: <main> --
|
||||||
|
package
|
||||||
|
|
||||||
|
public fun test(): kotlin.Unit
|
||||||
Generated
+46
@@ -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
|
@Nested
|
||||||
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
@TestMetadata("compiler/testData/diagnostics/tests/override/parameterNames")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
|||||||
+36
-5
@@ -11,17 +11,16 @@ import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFa
|
|||||||
import org.jetbrains.kotlin.checkers.utils.TypeOfCall
|
import org.jetbrains.kotlin.checkers.utils.TypeOfCall
|
||||||
import org.jetbrains.kotlin.diagnostics.*
|
import org.jetbrains.kotlin.diagnostics.*
|
||||||
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
|
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.analysis.diagnostics.FirErrors
|
||||||
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
|
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.FirFile
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
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.FirNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
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.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
@@ -156,7 +155,9 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunctionCall(functionCall: FirFunctionCall) {
|
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)
|
super.visitFunctionCall(functionCall)
|
||||||
}
|
}
|
||||||
@@ -166,10 +167,27 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
|
|||||||
if (selector is FirQualifiedAccess) {
|
if (selector is FirQualifiedAccess) {
|
||||||
val reference = selector.calleeReference as FirNamedReference
|
val reference = selector.calleeReference as FirNamedReference
|
||||||
consumer.reportCallDiagnostic(safeCallExpression, reference)
|
consumer.reportCallDiagnostic(safeCallExpression, reference)
|
||||||
|
consumer.reportContainingClassDiagnostic(safeCallExpression, reference)
|
||||||
}
|
}
|
||||||
|
|
||||||
super.visitSafeCallExpression(safeCallExpression)
|
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)
|
}.let(firFile::accept)
|
||||||
|
|
||||||
val codeMetaInfos = result.flatMap { diagnostic ->
|
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(
|
private fun getTypeOfCall(
|
||||||
reference: FirNamedReference,
|
reference: FirNamedReference,
|
||||||
resolvedSymbol: FirBasedSymbol<*>?
|
resolvedSymbol: FirBasedSymbol<*>?
|
||||||
@@ -253,7 +283,8 @@ private class DebugDiagnosticConsumer(
|
|||||||
KtRealSourceElementKind,
|
KtRealSourceElementKind,
|
||||||
KtFakeSourceElementKind.DesugaredCompoundAssignment,
|
KtFakeSourceElementKind.DesugaredCompoundAssignment,
|
||||||
KtFakeSourceElementKind.ReferenceInAtomicQualifiedAccess,
|
KtFakeSourceElementKind.ReferenceInAtomicQualifiedAccess,
|
||||||
KtFakeSourceElementKind.SmartCastExpression
|
KtFakeSourceElementKind.SmartCastExpression,
|
||||||
|
KtFakeSourceElementKind.DelegatingConstructorCall
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.AbstractDiagnosticCollector
|
||||||
import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector
|
import org.jetbrains.kotlin.fir.analysis.collectors.FirDiagnosticsCollector
|
||||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.*
|
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.FirFile
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirSmartCastExpression
|
|
||||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||||
import org.jetbrains.kotlin.fir.renderer.FirRenderer
|
import org.jetbrains.kotlin.fir.renderer.FirRenderer
|
||||||
@@ -133,7 +132,7 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
|
|||||||
KotlinTestUtils.assertEqualsToFile(file, actualText)
|
KotlinTestUtils.assertEqualsToFile(file, actualText)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun collectDebugInfoDiagnostics(
|
private fun collectDebugInfoDiagnostics(
|
||||||
firFile: FirFile,
|
firFile: FirFile,
|
||||||
diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>>
|
diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>>
|
||||||
): List<KtDiagnostic> {
|
): List<KtDiagnostic> {
|
||||||
@@ -154,12 +153,26 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunctionCall(functionCall: FirFunctionCall) {
|
override fun visitFunctionCall(functionCall: FirFunctionCall) {
|
||||||
result.addIfNotNull(
|
val reference = functionCall.calleeReference
|
||||||
createCallDiagnosticIfExpected(functionCall, functionCall.calleeReference, diagnosedRangesToDiagnosticNames)
|
result.addIfNotNull(createCallDiagnosticIfExpected(functionCall, reference, diagnosedRangesToDiagnosticNames))
|
||||||
)
|
result.addIfNotNull(createDerivedClassDiagnosticIfExpected(functionCall, reference, diagnosedRangesToDiagnosticNames))
|
||||||
|
|
||||||
super.visitFunctionCall(functionCall)
|
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)
|
}.let(firFile::accept)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
@@ -185,13 +198,29 @@ abstract class AbstractKtDiagnosticsTest : AbstractFirBaseDiagnosticsTest() {
|
|||||||
element: FirElement,
|
element: FirElement,
|
||||||
reference: FirNamedReference,
|
reference: FirNamedReference,
|
||||||
diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>>
|
diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>>
|
||||||
): KtDiagnosticWithParameters1<String>? =
|
): KtDiagnostic? {
|
||||||
DebugInfoDiagnosticFactory1.CALL.createDebugInfoDiagnostic(element, diagnosedRangesToDiagnosticNames) {
|
return DebugInfoDiagnosticFactory1.CALL.createDebugInfoDiagnostic(element, diagnosedRangesToDiagnosticNames) {
|
||||||
|
|
||||||
val resolvedSymbol = (reference as? FirResolvedNamedReference)?.resolvedSymbol
|
val resolvedSymbol = (reference as? FirResolvedNamedReference)?.resolvedSymbol
|
||||||
val fqName = resolvedSymbol?.fqNameUnsafe()
|
val fqName = resolvedSymbol?.fqNameUnsafe()
|
||||||
Renderers.renderCallInfo(fqName, getTypeOfCall(reference, resolvedSymbol))
|
Renderers.renderCallInfo(fqName, getTypeOfCall(reference, resolvedSymbol))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun createDerivedClassDiagnosticIfExpected(
|
||||||
|
element: FirElement,
|
||||||
|
reference: FirNamedReference,
|
||||||
|
diagnosedRangesToDiagnosticNames: MutableMap<IntRange, MutableSet<String>>
|
||||||
|
): 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(
|
private fun DebugInfoDiagnosticFactory1.createDebugInfoDiagnostic(
|
||||||
element: FirElement,
|
element: FirElement,
|
||||||
|
|||||||
Reference in New Issue
Block a user