Get a callable reference expression to report an error on it properly, taking into account possible wrapping
^KT-42620 Fixed
This commit is contained in:
+5
@@ -12108,6 +12108,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/inferTypeFromUnresolvedArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42620.kt")
|
||||
public void testKt42620() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoAmbiguityForDifferentFunctionTypes.kt")
|
||||
public void testNoAmbiguityForDifferentFunctionTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt");
|
||||
|
||||
+5
@@ -3013,6 +3013,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt38801.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42620.kt")
|
||||
public void testKt42620() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
|
||||
+5
-1
@@ -159,7 +159,11 @@ class DiagnosticReporterByTrackingStrategy(
|
||||
|
||||
CallableReferenceCandidatesAmbiguity::class.java -> {
|
||||
val ambiguityDiagnostic = diagnostic as CallableReferenceCandidatesAmbiguity
|
||||
val expression = ambiguityDiagnostic.argument.psiExpression.safeAs<KtCallableReferenceExpression>()
|
||||
val expression = when (val psiExpression = ambiguityDiagnostic.argument.psiExpression) {
|
||||
is KtPsiUtil.KtExpressionWrapper -> psiExpression.baseExpression
|
||||
else -> psiExpression
|
||||
}.safeAs<KtCallableReferenceExpression>()
|
||||
|
||||
val candidates = ambiguityDiagnostic.candidates.map { it.candidate }
|
||||
if (expression != null) {
|
||||
trace.reportDiagnosticOnce(CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY.on(expression.callableReference, candidates))
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class Foo
|
||||
|
||||
fun main1() = when {
|
||||
else -> <!UNRESOLVED_REFERENCE!>Foo::plus<!>
|
||||
}
|
||||
|
||||
fun main2() = if (true) Foo::minus else Foo::times
|
||||
|
||||
fun main3() = if (true) { Foo::minus } else { Foo::times }
|
||||
|
||||
fun main4() = try { Foo::minus } finally { <!UNRESOLVED_REFERENCE!>Foo::times<!> }
|
||||
|
||||
fun main5() = Foo::minus ?: Foo::times
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class Foo
|
||||
|
||||
fun main1() = when {
|
||||
else -> <!TYPE_MISMATCH!>Foo::plus<!>
|
||||
}
|
||||
|
||||
fun main2() = if (true) Foo::<!UNRESOLVED_REFERENCE!>minus<!> else Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
||||
|
||||
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main4() = try { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } finally { <!UNUSED_EXPRESSION!>Foo::<!UNRESOLVED_REFERENCE!>times<!><!> }
|
||||
|
||||
fun main5() = Foo::<!UNRESOLVED_REFERENCE!>minus<!> ?: Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
||||
@@ -0,0 +1,15 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class Foo
|
||||
|
||||
fun main1() = when {
|
||||
else -> <!UNRESOLVED_REFERENCE!>Foo::plus<!>
|
||||
}
|
||||
|
||||
fun main2() = if (true) <!UNRESOLVED_REFERENCE!>Foo::minus<!> else <!UNRESOLVED_REFERENCE!>Foo::times<!>
|
||||
|
||||
fun main3() = if (true) { <!UNRESOLVED_REFERENCE!>Foo::minus<!> } else { <!UNRESOLVED_REFERENCE!>Foo::times<!> }
|
||||
|
||||
fun main4() = try { <!UNRESOLVED_REFERENCE!>Foo::minus<!> } finally { <!UNRESOLVED_REFERENCE!>Foo::times<!> }
|
||||
|
||||
fun main5() = <!UNRESOLVED_REFERENCE!>Foo::minus<!> ?: <!UNRESOLVED_REFERENCE!>Foo::times<!>
|
||||
@@ -0,0 +1,15 @@
|
||||
// SKIP_TXT
|
||||
|
||||
class Foo
|
||||
|
||||
fun main1() = when {
|
||||
else -> Foo::<!CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY!>plus<!>
|
||||
}
|
||||
|
||||
fun main2() = if (true) Foo::<!CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY!>minus<!> else Foo::<!CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY!>times<!>
|
||||
|
||||
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>times<!> }
|
||||
|
||||
fun main4() = try { Foo::<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>minus<!> } finally { <!UNUSED_EXPRESSION!>Foo::<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>times<!><!> }
|
||||
|
||||
fun main5() = Foo::<!CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY!>minus<!> ?: Foo::<!CALLABLE_REFERENCE_RESOLUTION_AMBIGUITY!>times<!>
|
||||
@@ -12115,6 +12115,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/inferTypeFromUnresolvedArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42620.kt")
|
||||
public void testKt42620() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoAmbiguityForDifferentFunctionTypes.kt")
|
||||
public void testNoAmbiguityForDifferentFunctionTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt");
|
||||
|
||||
+5
@@ -3163,6 +3163,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt38801.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42620.kt")
|
||||
public void testKt42620() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
|
||||
compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java
Generated
+5
@@ -3163,6 +3163,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt38801.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42620.kt")
|
||||
public void testKt42620() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt42620.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt4975.kt")
|
||||
public void testKt4975() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt4975.kt");
|
||||
|
||||
Generated
+5
@@ -12110,6 +12110,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/inferTypeFromUnresolvedArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt42620.kt")
|
||||
public void testKt42620() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/kt42620.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("NoAmbiguityForDifferentFunctionTypes.kt")
|
||||
public void testNoAmbiguityForDifferentFunctionTypes() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/inference/reportingImprovements/NoAmbiguityForDifferentFunctionTypes.kt");
|
||||
|
||||
+5
-5
@@ -14799,6 +14799,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/anySuperCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fieldNameClash.kt")
|
||||
public void ignoreFieldNameClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("inlineClassWithCustomEquals.kt")
|
||||
public void ignoreInlineClassWithCustomEquals() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/inlineClassWithCustomEquals.kt");
|
||||
@@ -15102,11 +15107,6 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/extLambdaInInlineClassFun2.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("fieldNameClash.kt")
|
||||
public void testFieldNameClash() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/fieldNameClash.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("genericInlineClassSynthMembers.kt")
|
||||
public void testGenericInlineClassSynthMembers() throws Exception {
|
||||
runTest("compiler/testData/codegen/box/inlineClasses/genericInlineClassSynthMembers.kt");
|
||||
|
||||
Reference in New Issue
Block a user