diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index d94a2951c9f..27e226ba113 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -10295,6 +10295,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt"); } + @TestMetadata("kt32388.kt") + public void testKt32388() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt"); + } + @TestMetadata("lambdaNothingAndExpectedType.kt") public void testLambdaNothingAndExpectedType() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.kt"); diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt b/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt new file mode 100644 index 00000000000..c856bef6bef --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt @@ -0,0 +1,13 @@ +// !WITH_NEW_INFERENCE + +fun Either.recover(f: (A) -> B): Either = when (this) { + is Either.Left -> f(this.a).right() + is Either.Right -> this +} + +fun A.right(): Either = Either.Right(this) + +sealed class Either { + class Left constructor(val a: A) : Either() + class Right constructor(val b: B) : Either() +} diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt b/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt new file mode 100644 index 00000000000..790a1da91cd --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/kt32388.txt @@ -0,0 +1,27 @@ +package + +public fun Either.recover(/*0*/ f: (A) -> B): Either +public fun A.right(): Either + +public sealed class Either { + private constructor Either() + 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 Left : Either { + public constructor Left(/*0*/ a: A) + public final val a: A + 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 Right : Either { + public constructor Right(/*0*/ b: B) + public final val b: B + 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/kt32271.kt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.kt new file mode 100644 index 00000000000..3b036fe1dac --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.kt @@ -0,0 +1,29 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER + +suspend fun threadSafeSuspendCallback(startAsync: (CompletionLambda) -> CancellationLambda): T = TODO() +typealias CompletionLambda = (result: Result) -> Unit +typealias CancellationLambda = () -> Unit + +class Scope { + suspend fun performAndWait(block: suspend CoroutineScope.() -> T): T { + return CoroutineWorker().run { + val result = threadSafeSuspendCallback { completion -> + val workItem = WorkItem { + val result = runCatching { + block() + } + completion(result) + } + return@threadSafeSuspendCallback { Unit } + } + result + } + } + + class WorkItem( + val block: suspend CoroutineScope.() -> Unit + ) +} + +class CoroutineWorker +interface CoroutineScope \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.txt b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.txt new file mode 100644 index 00000000000..e0fe9539cbb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.txt @@ -0,0 +1,34 @@ +package + +public suspend fun threadSafeSuspendCallback(/*0*/ startAsync: (CompletionLambda /* = (result: kotlin.Result) -> kotlin.Unit */) -> CancellationLambda /* = () -> kotlin.Unit */): T + +public interface CoroutineScope { + 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 CoroutineWorker { + public constructor CoroutineWorker() + 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 Scope { + public constructor Scope() + 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 final suspend fun performAndWait(/*0*/ block: suspend CoroutineScope.() -> T): T + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class WorkItem { + public constructor WorkItem(/*0*/ block: suspend CoroutineScope.() -> kotlin.Unit) + public final val block: suspend CoroutineScope.() -> kotlin.Unit + 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 typealias CancellationLambda = () -> kotlin.Unit +public typealias CompletionLambda = (result: kotlin.Result) -> kotlin.Unit diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt new file mode 100644 index 00000000000..4e73147cdc6 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt @@ -0,0 +1,26 @@ +fun test1(ns: String?, vararg nullableStrs: String?) { + nullableStrs.contains("x") + nullableStrs.contains(ns) + "x" in nullableStrs + ns in nullableStrs +} + +fun test2(ns: String?, vararg nonNullableStrs: String) { + nonNullableStrs.contains("x") + nonNullableStrs.contains(ns) + "x" in nonNullableStrs + ns in nonNullableStrs +} + +fun test3(ns: String?, nullableStrs: Array, nonNullableStrs: Array) { + nullableStrs.contains("x") + nonNullableStrs.contains("x") + + nullableStrs.contains(ns) + nonNullableStrs.contains(ns) + + "x" in nullableStrs + "x" in nonNullableStrs + ns in nullableStrs + ns in nonNullableStrs +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.txt new file mode 100644 index 00000000000..bd74940b2bc --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.txt @@ -0,0 +1,5 @@ +package + +public fun test1(/*0*/ ns: kotlin.String?, /*1*/ vararg nullableStrs: kotlin.String? /*kotlin.Array*/): kotlin.Unit +public fun test2(/*0*/ ns: kotlin.String?, /*1*/ vararg nonNullableStrs: kotlin.String /*kotlin.Array*/): kotlin.Unit +public fun test3(/*0*/ ns: kotlin.String?, /*1*/ nullableStrs: kotlin.Array, /*2*/ nonNullableStrs: kotlin.Array): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 7b08f38f184..ac060518cdd 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10302,6 +10302,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt"); } + @TestMetadata("kt32388.kt") + public void testKt32388() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt"); + } + @TestMetadata("lambdaNothingAndExpectedType.kt") public void testLambdaNothingAndExpectedType() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 8cf58532542..dba56983255 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -1887,6 +1887,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt"); } + @TestMetadata("kt32271.kt") + public void testKt32271() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.kt"); + } + @TestMetadata("nestedLambdaInferenceWithListMap.kt") public void testNestedLambdaInferenceWithListMap() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/nestedLambdaInferenceWithListMap.kt"); @@ -2813,6 +2818,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt"); } + @TestMetadata("onlyInputTypesWithVarargs.kt") + public void testOnlyInputTypesWithVarargs() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt"); + } + @TestMetadata("propagationOfNoInferAnnotation.kt") public void testPropagationOfNoInferAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index fd30f2d8039..c0ff3e177a6 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -1887,6 +1887,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt15516.kt"); } + @TestMetadata("kt32271.kt") + public void testKt32271() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/kt32271.kt"); + } + @TestMetadata("nestedLambdaInferenceWithListMap.kt") public void testNestedLambdaInferenceWithListMap() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/coroutines/inference/nestedLambdaInferenceWithListMap.kt"); @@ -2813,6 +2818,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesCaptured.kt"); } + @TestMetadata("onlyInputTypesWithVarargs.kt") + public void testOnlyInputTypesWithVarargs() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/onlyInputTypesWithVarargs.kt"); + } + @TestMetadata("propagationOfNoInferAnnotation.kt") public void testPropagationOfNoInferAnnotation() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/propagationOfNoInferAnnotation.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 2adb692c6e1..4a237e23de7 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10297,6 +10297,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt"); } + @TestMetadata("kt32388.kt") + public void testKt32388() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt"); + } + @TestMetadata("lambdaNothingAndExpectedType.kt") public void testLambdaNothingAndExpectedType() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/lambdaNothingAndExpectedType.kt");