[Test] Reproduce KT-65576

This commit is contained in:
Dmitriy Novozhilov
2024-02-26 13:25:37 +02:00
committed by Space Team
parent 91e9fbd9bf
commit 234cc5be2b
7 changed files with 114 additions and 0 deletions
@@ -28302,6 +28302,12 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/EqualsOperatorOverrideHierarchies.kt");
}
@Test
@TestMetadata("implicitInvokeOnPropertyInItsInitializer.kt")
public void testImplicitInvokeOnPropertyInItsInitializer() {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/implicitInvokeOnPropertyInItsInitializer.kt");
}
@Test
@TestMetadata("incForAssignmentSmartCast.kt")
public void testIncForAssignmentSmartCast() {
@@ -28302,6 +28302,12 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/EqualsOperatorOverrideHierarchies.kt");
}
@Test
@TestMetadata("implicitInvokeOnPropertyInItsInitializer.kt")
public void testImplicitInvokeOnPropertyInItsInitializer() {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/implicitInvokeOnPropertyInItsInitializer.kt");
}
@Test
@TestMetadata("incForAssignmentSmartCast.kt")
public void testIncForAssignmentSmartCast() {
@@ -26012,6 +26012,12 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/EqualsOperatorOverrideHierarchies.kt");
}
@Test
@TestMetadata("implicitInvokeOnPropertyInItsInitializer.kt")
public void testImplicitInvokeOnPropertyInItsInitializer() {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/implicitInvokeOnPropertyInItsInitializer.kt");
}
@Test
@TestMetadata("incForAssignmentSmartCast.kt")
public void testIncForAssignmentSmartCast() {
@@ -26018,6 +26018,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/EqualsOperatorOverrideHierarchies.kt");
}
@Test
@TestMetadata("implicitInvokeOnPropertyInItsInitializer.kt")
public void testImplicitInvokeOnPropertyInItsInitializer() {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/implicitInvokeOnPropertyInItsInitializer.kt");
}
@Test
@TestMetadata("incForAssignmentSmartCast.kt")
public void testIncForAssignmentSmartCast() {
@@ -0,0 +1,42 @@
// ISSUE: KT-65576
fun foo(): Int = 0
object Implicit {
operator fun Any.invoke(): String = "Fail"
val foo = foo()
}
object Explicit {
operator fun Any.invoke(): String = "Fail"
val foo: String = foo()
}
class Inv<T>(val value: T)
object ImplicitWrapped {
operator fun Inv<*>.invoke(): Inv<String> = Inv("Fail")
val foo = Inv(<!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>foo<!>)()
}
object ImplicitIndirect {
operator fun Any.invoke(): String = "Fail"
val foo get() = bar()
val bar get() = baz()
val baz get() = foo()
}
fun takeInt(x: Int) {}
fun test() {
takeInt(<!ARGUMENT_TYPE_MISMATCH!>Implicit.foo<!>) // should be an error
takeInt(<!ARGUMENT_TYPE_MISMATCH!>Explicit.foo<!>) // should be an error
takeInt(<!ARGUMENT_TYPE_MISMATCH!>ImplicitWrapped.foo<!>) // should be an error
takeInt(<!ARGUMENT_TYPE_MISMATCH!>ImplicitIndirect.foo<!>) // should be an error
takeInt(<!ARGUMENT_TYPE_MISMATCH!>ImplicitIndirect.bar<!>) // should be an error
takeInt(<!ARGUMENT_TYPE_MISMATCH!>ImplicitIndirect.baz<!>) // should be an error
}
@@ -0,0 +1,42 @@
// ISSUE: KT-65576
fun foo(): Int = 0
object Implicit {
operator fun Any.invoke(): String = "Fail"
val foo = foo()
}
object Explicit {
operator fun Any.invoke(): String = "Fail"
val foo: String = <!DEBUG_INFO_LEAKING_THIS, UNINITIALIZED_VARIABLE!>foo<!>()
}
class Inv<T>(val value: T)
object ImplicitWrapped {
operator fun Inv<*>.invoke(): Inv<String> = Inv("Fail")
val foo = Inv(<!DEBUG_INFO_MISSING_UNRESOLVED, TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM_ERROR!>foo<!>)()
}
object ImplicitIndirect {
operator fun Any.invoke(): String = "Fail"
val foo get() = bar()
val bar get() = baz()
val baz get() = foo()
}
fun takeInt(x: Int) {}
fun test() {
takeInt(Implicit.foo) // should be an error
takeInt(<!TYPE_MISMATCH!>Explicit.foo<!>) // should be an error
takeInt(ImplicitWrapped.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>foo<!>) // should be an error
takeInt(<!TYPE_MISMATCH!>ImplicitIndirect.foo<!>) // should be an error
takeInt(<!TYPE_MISMATCH!>ImplicitIndirect.bar<!>) // should be an error
takeInt(ImplicitIndirect.baz) // should be an error
}
@@ -28302,6 +28302,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/EqualsOperatorOverrideHierarchies.kt");
}
@Test
@TestMetadata("implicitInvokeOnPropertyInItsInitializer.kt")
public void testImplicitInvokeOnPropertyInItsInitializer() {
runTest("compiler/testData/diagnostics/tests/operatorsOverloading/implicitInvokeOnPropertyInItsInitializer.kt");
}
@Test
@TestMetadata("incForAssignmentSmartCast.kt")
public void testIncForAssignmentSmartCast() {