K2: Fix current behavior for KT-37375 and KT-58943
This commit is contained in:
committed by
Space Team
parent
f37dc27974
commit
acb1859154
+18
@@ -27449,6 +27449,18 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/invoke"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closeInvokesFarVariable.kt")
|
||||
public void testCloseInvokesFarVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closeInvokesFarVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closerVariableMatterMore.kt")
|
||||
public void testCloserVariableMatterMore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closerVariableMatterMore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("completePropertyBeforeInvoke.kt")
|
||||
public void testCompletePropertyBeforeInvoke() throws Exception {
|
||||
@@ -27467,6 +27479,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitAndInvokeExtensionPriority.kt")
|
||||
public void testImplicitAndInvokeExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/implicitAndInvokeExtensionPriority.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitInvoke.kt")
|
||||
public void testImplicitInvoke() throws Exception {
|
||||
|
||||
+18
@@ -27449,6 +27449,18 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/invoke"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closeInvokesFarVariable.kt")
|
||||
public void testCloseInvokesFarVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closeInvokesFarVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closerVariableMatterMore.kt")
|
||||
public void testCloserVariableMatterMore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closerVariableMatterMore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("completePropertyBeforeInvoke.kt")
|
||||
public void testCompletePropertyBeforeInvoke() throws Exception {
|
||||
@@ -27467,6 +27479,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitAndInvokeExtensionPriority.kt")
|
||||
public void testImplicitAndInvokeExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/implicitAndInvokeExtensionPriority.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitInvoke.kt")
|
||||
public void testImplicitInvoke() throws Exception {
|
||||
|
||||
+18
@@ -27449,6 +27449,18 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/invoke"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closeInvokesFarVariable.kt")
|
||||
public void testCloseInvokesFarVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closeInvokesFarVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closerVariableMatterMore.kt")
|
||||
public void testCloserVariableMatterMore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closerVariableMatterMore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("completePropertyBeforeInvoke.kt")
|
||||
public void testCompletePropertyBeforeInvoke() throws Exception {
|
||||
@@ -27467,6 +27479,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitAndInvokeExtensionPriority.kt")
|
||||
public void testImplicitAndInvokeExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/implicitAndInvokeExtensionPriority.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitInvoke.kt")
|
||||
public void testImplicitInvoke() throws Exception {
|
||||
|
||||
+18
@@ -27461,6 +27461,18 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/invoke"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closeInvokesFarVariable.kt")
|
||||
public void testCloseInvokesFarVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closeInvokesFarVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closerVariableMatterMore.kt")
|
||||
public void testCloserVariableMatterMore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closerVariableMatterMore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("completePropertyBeforeInvoke.kt")
|
||||
public void testCompletePropertyBeforeInvoke() throws Exception {
|
||||
@@ -27479,6 +27491,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitAndInvokeExtensionPriority.kt")
|
||||
public void testImplicitAndInvokeExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/implicitAndInvokeExtensionPriority.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitInvoke.kt")
|
||||
public void testImplicitInvoke() throws Exception {
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-37375
|
||||
|
||||
val foo: Any = Any()
|
||||
|
||||
fun bar() {
|
||||
operator fun Any.invoke(): String = ""
|
||||
|
||||
fun baz() {
|
||||
operator fun Any.invoke(): Int = 1
|
||||
|
||||
fun barbaz() {
|
||||
takeInt(<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
// ISSUE: KT-37375
|
||||
|
||||
val foo: Any = Any()
|
||||
|
||||
fun bar() {
|
||||
operator fun Any.invoke(): String = ""
|
||||
|
||||
fun baz() {
|
||||
operator fun Any.invoke(): Int = 1
|
||||
|
||||
fun barbaz() {
|
||||
takeInt(foo())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// ISSUE: KT-37375
|
||||
|
||||
fun takeDouble(x: Double) {}
|
||||
|
||||
val bar: Int = 1
|
||||
operator fun Double.invoke(): Double = 1.0 // (1)
|
||||
|
||||
fun test_1() {
|
||||
val bar: Double = 2.0
|
||||
operator fun Int.invoke(): Int = 1 // (2)
|
||||
|
||||
val res = bar() // should resolve to (1)
|
||||
takeDouble(<!ARGUMENT_TYPE_MISMATCH!>res<!>) // should be OK
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// ISSUE: KT-37375
|
||||
|
||||
fun takeDouble(x: Double) {}
|
||||
|
||||
val bar: Int = 1
|
||||
operator fun Double.invoke(): Double = 1.0 // (1)
|
||||
|
||||
fun test_1() {
|
||||
val bar: Double = 2.0
|
||||
operator fun Int.invoke(): Int = 1 // (2)
|
||||
|
||||
val res = bar() // should resolve to (1)
|
||||
takeDouble(res) // should be OK
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
// ISSUE: KT-58943
|
||||
|
||||
class A {
|
||||
fun bar() {
|
||||
val foo: String.() -> Int = { 1 } // (1)
|
||||
fun String.foo(): String = "" // (2)
|
||||
with("2") {
|
||||
// In K1, foo variable + invokeExtension on implicit receiver is more prioritized than `foo() + implicit receiver`
|
||||
// So, for now, we're going to preserve that behavior in K2
|
||||
// For design, see KT-59528
|
||||
takeInt(<!ARGUMENT_TYPE_MISMATCH!>foo()<!>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// ISSUE: KT-58943
|
||||
|
||||
class A {
|
||||
fun bar() {
|
||||
val foo: String.() -> Int = { 1 } // (1)
|
||||
fun String.foo(): String = "" // (2)
|
||||
with("2") {
|
||||
// In K1, foo variable + invokeExtension on implicit receiver is more prioritized than `foo() + implicit receiver`
|
||||
// So, for now, we're going to preserve that behavior in K2
|
||||
// For design, see KT-59528
|
||||
takeInt(foo())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun takeInt(x: Int) {}
|
||||
Generated
+18
@@ -28293,6 +28293,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/resolve/invoke"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closeInvokesFarVariable.kt")
|
||||
public void testCloseInvokesFarVariable() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closeInvokesFarVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("closerVariableMatterMore.kt")
|
||||
public void testCloserVariableMatterMore() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/closerVariableMatterMore.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("completePropertyBeforeInvoke.kt")
|
||||
public void testCompletePropertyBeforeInvoke() throws Exception {
|
||||
@@ -28311,6 +28323,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitAndInvokeExtensionPriority.kt")
|
||||
public void testImplicitAndInvokeExtensionPriority() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/resolve/invoke/implicitAndInvokeExtensionPriority.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("implicitInvoke.kt")
|
||||
public void testImplicitInvoke() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user