diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java index 9c076bcbb2f..60cf693cf65 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestGenerated.java @@ -1779,6 +1779,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/callableReference/callableReferenceAsLastExpressionInBlock.kt"); } + @TestMetadata("callableReferenceToLocalVariable.kt") + public void testCallableReferenceToLocalVariable() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.kt"); + } + @TestMetadata("classVsPackage.kt") public void testClassVsPackage() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/classVsPackage.kt"); @@ -17295,6 +17300,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/regressions/kt10843.kt"); } + @TestMetadata("kt11979.kt") + public void testKt11979() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt11979.kt"); + } + @TestMetadata("kt127.kt") public void testKt127() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt127.kt"); @@ -17305,6 +17315,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte runTest("compiler/testData/diagnostics/tests/regressions/kt128.kt"); } + @TestMetadata("kt12898.kt") + public void testKt12898() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt12898.kt"); + } + @TestMetadata("kt13685.kt") public void testKt13685() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt13685.kt"); diff --git a/compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.kt b/compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.kt new file mode 100644 index 00000000000..246b540fdbd --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +fun a() { + val x = 10 + foo(::x) +} + +fun foo(a: Any) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.txt b/compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.txt new file mode 100644 index 00000000000..f05b52a12b4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.txt @@ -0,0 +1,4 @@ +package + +public fun a(): kotlin.Unit +public fun foo(/*0*/ a: kotlin.Any): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/regressions/kt11979.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt11979.fir.kt new file mode 100644 index 00000000000..9402f2990e2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt11979.fir.kt @@ -0,0 +1,26 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE + + +interface Bar { + val t: T +} + +class MyBar(override val t: T) : Bar + +class BarR : Bar { + override val t: BarR get() = this +} + +class Foo>(val f: F) + +fun id(t1: T, t2: T) = t2 + +fun test(foo: Foo<*>, g: Bar<*>) { + id(foo.f, g).t.t +} + +fun main() { + val foo = Foo(BarR()) + test(foo, MyBar(2)) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt11979.kt b/compiler/testData/diagnostics/tests/regressions/kt11979.kt new file mode 100644 index 00000000000..cc51a11a15d --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt11979.kt @@ -0,0 +1,26 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE + + +interface Bar { + val t: T +} + +class MyBar(override val t: T) : Bar + +class BarR : Bar { + override val t: BarR get() = this +} + +class Foo>(val f: F) + +fun id(t1: T, t2: T) = t2 + +fun test(foo: Foo<*>, g: Bar<*>) { + id(foo.f, g).t.t +} + +fun main() { + val foo = Foo(BarR()) + test(foo, MyBar(2)) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt11979.txt b/compiler/testData/diagnostics/tests/regressions/kt11979.txt new file mode 100644 index 00000000000..d9e55bf3c34 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt11979.txt @@ -0,0 +1,36 @@ +package + +public fun id(/*0*/ t1: T, /*1*/ t2: T): T +public fun main(): kotlin.Unit +public fun test(/*0*/ foo: Foo<*>, /*1*/ g: Bar<*>): kotlin.Unit + +public interface Bar { + public abstract val t: 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 +} + +public final class BarR : Bar { + public constructor BarR() + public open override /*1*/ val t: BarR + 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 final class Foo> { + public constructor Foo>(/*0*/ f: F) + public final val f: F + 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 final class MyBar : Bar { + public constructor MyBar(/*0*/ t: T) + public open override /*1*/ val t: 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/regressions/kt12898.fir.kt b/compiler/testData/diagnostics/tests/regressions/kt12898.fir.kt new file mode 100644 index 00000000000..ce0ae536fcd --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt12898.fir.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +NewInference +// !WITH_NEW_INFERENCE + +interface B { + val t: T +} + +class C(override val t: Any?) : B + +fun f(b: B<*, Any>) { + val y = b.t + if (y is String?) { + y.length + } +} + +fun main() { + f(C("hello")) + f(C(null)) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt12898.kt b/compiler/testData/diagnostics/tests/regressions/kt12898.kt new file mode 100644 index 00000000000..72f52c800ee --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt12898.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +NewInference +// !WITH_NEW_INFERENCE + +interface B { + val t: T +} + +class C(override val t: Any?) : B + +fun f(b: B<*, Any>) { + val y = b.t + if (y is String?) { + y.length + } +} + +fun main() { + f(C("hello")) + f(C(null)) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt12898.txt b/compiler/testData/diagnostics/tests/regressions/kt12898.txt new file mode 100644 index 00000000000..8483850ffe5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt12898.txt @@ -0,0 +1,19 @@ +package + +public fun f(/*0*/ b: B<*, kotlin.Any>): kotlin.Unit +public fun main(): kotlin.Unit + +public interface B { + public abstract val t: 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 +} + +public final class C : B { + public constructor C(/*0*/ t: kotlin.Any?) + public open override /*1*/ val 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 +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.kt new file mode 100644 index 00000000000..ab366f7d6a7 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.kt @@ -0,0 +1,19 @@ +// !USE_EXPERIMENTAL: kotlin.Experimental +// !DIAGNOSTICS: -UNUSED_EXPRESSION -UNUSED_PARAMETER -UNUSED_VARIABLE + +@file:UseExperimental(ExperimentalTypeInference::class) + +import kotlin.experimental.ExperimentalTypeInference + +interface ProducerScope { + fun yield(e: E) +} + +@UseExperimental(ExperimentalTypeInference::class) +fun produce(@BuilderInference block: ProducerScope.() -> Unit): ProducerScope = TODO() + +fun filter(e: K, predicate: (K) -> Boolean) = + produce { + predicate(e) + yield(42) + } \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.txt new file mode 100644 index 00000000000..b25dc46daed --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.txt @@ -0,0 +1,11 @@ +package + +public fun filter(/*0*/ e: K, /*1*/ predicate: (K) -> kotlin.Boolean): ProducerScope +@kotlin.UseExperimental(markerClass = {kotlin.experimental.ExperimentalTypeInference::class}) public fun produce(/*0*/ @kotlin.BuilderInference block: ProducerScope.() -> kotlin.Unit): ProducerScope + +public interface ProducerScope { + 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 abstract fun yield(/*0*/ e: E): kotlin.Unit +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 225cb72189f..ecd1b909114 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1786,6 +1786,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/callableReference/callableReferenceAsLastExpressionInBlock.kt"); } + @TestMetadata("callableReferenceToLocalVariable.kt") + public void testCallableReferenceToLocalVariable() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.kt"); + } + @TestMetadata("classVsPackage.kt") public void testClassVsPackage() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/classVsPackage.kt"); @@ -17307,6 +17312,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/regressions/kt10843.kt"); } + @TestMetadata("kt11979.kt") + public void testKt11979() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt11979.kt"); + } + @TestMetadata("kt127.kt") public void testKt127() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt127.kt"); @@ -17317,6 +17327,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/regressions/kt128.kt"); } + @TestMetadata("kt12898.kt") + public void testKt12898() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt12898.kt"); + } + @TestMetadata("kt13685.kt") public void testKt13685() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt13685.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 9f08ad7b863..ab65326aacd 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1997,6 +1997,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt"); } + @TestMetadata("variableOfAFunctionTypeCall.kt") + public void testVariableOfAFunctionTypeCall() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.kt"); + } + @TestMetadata("withParameter.kt") public void testWithParameter() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 2df8827e3d7..b9ab7cab1f3 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1997,6 +1997,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableCallInsideBuilderFunction.kt"); } + @TestMetadata("variableOfAFunctionTypeCall.kt") + public void testVariableOfAFunctionTypeCall() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/variableOfAFunctionTypeCall.kt"); + } + @TestMetadata("withParameter.kt") public void testWithParameter() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/withParameter.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 6a9289568c6..8430a0e9b9c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1781,6 +1781,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/callableReference/callableReferenceAsLastExpressionInBlock.kt"); } + @TestMetadata("callableReferenceToLocalVariable.kt") + public void testCallableReferenceToLocalVariable() throws Exception { + runTest("compiler/testData/diagnostics/tests/callableReference/callableReferenceToLocalVariable.kt"); + } + @TestMetadata("classVsPackage.kt") public void testClassVsPackage() throws Exception { runTest("compiler/testData/diagnostics/tests/callableReference/classVsPackage.kt"); @@ -17297,6 +17302,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/kt10843.kt"); } + @TestMetadata("kt11979.kt") + public void testKt11979() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt11979.kt"); + } + @TestMetadata("kt127.kt") public void testKt127() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt127.kt"); @@ -17307,6 +17317,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/kt128.kt"); } + @TestMetadata("kt12898.kt") + public void testKt12898() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt12898.kt"); + } + @TestMetadata("kt13685.kt") public void testKt13685() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt13685.kt");