From 65213e9a4250c37778ee7d911847cfcdfa845272 Mon Sep 17 00:00:00 2001 From: Victor Petukhov Date: Fri, 11 Feb 2022 11:49:59 +0300 Subject: [PATCH] [FE 1.0] Report warnings or errors for upper bounded type variables by an empty intersection type --- .../jetbrains/kotlin/diagnostics/Errors.java | 2 ++ .../rendering/DefaultErrorMessages.java | 1 + .../DiagnosticReporterByTrackingStrategy.kt | 15 ++++++++ .../coercionToUnitWithNothingType.kt | 2 +- ...romCovariantAndContravariantTypes.diag.txt | 12 +++++++ ...electFromCovariantAndContravariantTypes.kt | 4 +-- ...eWhenVariableHasComplexIntersectionType.kt | 2 +- .../postponedArgumentsAnalysis/basic.kt | 8 ++--- .../tests/inference/kt45461.diag.txt | 6 ++++ .../diagnostics/tests/inference/kt45461.kt | 11 ++++++ .../diagnostics/tests/inference/kt45461.txt | 18 ++++++++++ .../tests/inference/kt48765.diag.txt | 15 ++++++++ .../diagnostics/tests/inference/kt48765.kt | 17 +++++++++ .../diagnostics/tests/inference/kt48765.txt | 36 +++++++++++++++++++ .../tests/inference/kt48935.diag.txt | 7 ++++ .../diagnostics/tests/inference/kt48935.kt | 13 +++++++ .../diagnostics/tests/inference/kt48935.txt | 17 +++++++++ .../tests/inference/kt49661.diag.txt | 4 +++ .../diagnostics/tests/inference/kt49661.kt | 11 ++++++ .../diagnostics/tests/inference/kt49661.txt | 12 +++++++ .../inference/selectOfLambdaWithExtension.kt | 2 +- .../selectOfLambdaWithExtensionDisabled.kt | 2 +- .../specialConstructions/elvisAsCall.kt | 2 +- .../specialConstructions/exclExclAsCall.kt | 2 +- .../test/runners/DiagnosticTestGenerated.java | 24 +++++++++++++ 25 files changed, 233 insertions(+), 12 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.diag.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt45461.diag.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt45461.kt create mode 100644 compiler/testData/diagnostics/tests/inference/kt45461.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt48765.diag.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt48765.kt create mode 100644 compiler/testData/diagnostics/tests/inference/kt48765.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt48935.diag.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt48935.kt create mode 100644 compiler/testData/diagnostics/tests/inference/kt48935.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt49661.diag.txt create mode 100644 compiler/testData/diagnostics/tests/inference/kt49661.kt create mode 100644 compiler/testData/diagnostics/tests/inference/kt49661.txt diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 26afe66774c..852ef6c393b 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -897,6 +897,8 @@ public interface Errors { DiagnosticFactoryForDeprecation1 TYPE_INFERENCE_ONLY_INPUT_TYPES = DiagnosticFactoryForDeprecation1.create(LanguageFeature.StrictOnlyInputTypesChecks); + DiagnosticFactoryForDeprecation2> INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION = + DiagnosticFactoryForDeprecation2.create(LanguageFeature.ForbidInferringTypeVariablesIntoEmptyIntersection); DiagnosticFactory1 TYPE_INFERENCE_UPPER_BOUND_VIOLATED = DiagnosticFactory1.create(ERROR); DiagnosticFactory2 TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH = DiagnosticFactory2.create(ERROR); DiagnosticFactory0 TYPE_INFERENCE_CANDIDATE_WITH_SAM_AND_VARARG = DiagnosticFactory0.create(WARNING); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index de43ee99b0d..f8a97fab308 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -964,6 +964,7 @@ public class DefaultErrorMessages { MAP.put(TYPE_INFERENCE_INCORPORATION_ERROR, "Type inference failed. Please try to specify type arguments explicitly."); MAP.put(TYPE_INFERENCE_ONLY_INPUT_TYPES, "Type inference failed. The value of the type parameter {0} should be mentioned in input types " + "(argument types, receiver type or expected type). Try to specify it explicitly.", NAME); + MAP.put(INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION, "Type argument for a type parameter {0} can''t be inferred because it''s upper bounded by incompatible types: {1}", TO_STRING, RENDER_COLLECTION_OF_TYPES); MAP.put(TYPE_INFERENCE_UPPER_BOUND_VIOLATED, "{0}", TYPE_INFERENCE_UPPER_BOUND_VIOLATED_RENDERER); MAP.put(TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, "Type inference failed. Expected type mismatch: inferred type is {1} but {0} was expected", RENDER_TYPE, RENDER_TYPE); MAP.put(TYPE_INFERENCE_CANDIDATE_WITH_SAM_AND_VARARG, "Please use spread operator to pass an array as vararg. It will be an error in 1.5."); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt index 1b8edb91ac5..9583fb36bed 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/DiagnosticReporterByTrackingStrategy.kt @@ -601,6 +601,21 @@ class DiagnosticReporterByTrackingStrategy( ) } } + + InferredEmptyIntersectionError::class.java, InferredEmptyIntersectionWarning::class.java -> { + val typeVariable = (error as InferredEmptyIntersection).typeVariable + psiKotlinCall.psiCall.calleeExpression?.let { + val typeVariableText = (typeVariable as? TypeVariableFromCallableDescriptor)?.originalTypeParameter?.name?.asString() + ?: typeVariable.toString() + trace.reportDiagnosticOnce( + @Suppress("UNCHECKED_CAST") + INFERRED_TYPE_VARIABLE_INTO_EMPTY_INTERSECTION.on( + context.languageVersionSettings, it, typeVariableText, + error.incompatibleTypes as Collection + ) + ) + } + } } } diff --git a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.kt b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.kt index 1eb84b4ea24..974c277310d 100644 --- a/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.kt +++ b/compiler/testData/diagnostics/tests/inference/coercionToUnit/coercionToUnitWithNothingType.kt @@ -47,7 +47,7 @@ fun test(i: Inv, iUnit: Inv) { if (iUnit is String) { launch { - run(A.flexible(iUnit)) { 42 } + run(A.flexible(iUnit)) { 42 } } } } diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.diag.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.diag.txt new file mode 100644 index 00000000000..60d06aee45e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.diag.txt @@ -0,0 +1,12 @@ +/selectFromCovariantAndContravariantTypes.kt:12:22: warning: parameter 'y' is never used +fun select(x: K, y: K): K = x + ^ +/selectFromCovariantAndContravariantTypes.kt:13:19: warning: parameter 'x' is never used +fun genericIn(x: In) {} + ^ +/selectFromCovariantAndContravariantTypes.kt:14:20: warning: parameter 'x' is never used +fun genericOut(x: Out) {} + ^ +/selectFromCovariantAndContravariantTypes.kt:17:5: warning: type argument for a type parameter V can't be inferred because it's upper bounded by incompatible types: A, B. This will become an error in Kotlin 1.8 + genericIn(select(a, b)) + ^ diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt index 9d313f973af..1752417dc17 100644 --- a/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt @@ -1,4 +1,4 @@ -// FIR_IDENTICAL +// RENDER_DIAGNOSTICS_FULL_TEXT // !LANGUAGE: +NewInference // !DIAGNOSTICS: -UNUSED_PARAMETER @@ -13,7 +13,7 @@ fun genericIn(x: In) {} fun genericOut(x: Out) {} fun test1(a: In, b: In) { - genericIn(select(a, b)) + genericIn(select(a, b)) } fun test2(a: Out, b: Out) { diff --git a/compiler/testData/diagnostics/tests/inference/compatibilityResolveWhenVariableHasComplexIntersectionType.kt b/compiler/testData/diagnostics/tests/inference/compatibilityResolveWhenVariableHasComplexIntersectionType.kt index 2e5b6620375..2b5160ada7c 100644 --- a/compiler/testData/diagnostics/tests/inference/compatibilityResolveWhenVariableHasComplexIntersectionType.kt +++ b/compiler/testData/diagnostics/tests/inference/compatibilityResolveWhenVariableHasComplexIntersectionType.kt @@ -20,7 +20,7 @@ object OnlyOne { fun , S : T> greater(x: Bar, t: T) {} fun test(b: Bar) { - greater(b, b) + greater(b, b) } } diff --git a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt index 655dff3faab..f50aa730101 100644 --- a/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt +++ b/compiler/testData/diagnostics/tests/inference/completion/postponedArgumentsAnalysis/basic.kt @@ -164,10 +164,10 @@ fun main() { select({ x, y -> x.inv() + y.toByte() }, id { x: Int, y -> y.toByte() }, id { x, y: Number -> x.inv() }) // Inferring lambda parameter types by other specified lambda parameters; expected type is a functional type with type variables in parameter types - takeLambdas({ it }, { x: Int -> }, { x: Nothing -> x }) - takeLambdas({ it }, { } as (Int) -> Unit, { x: Nothing -> x }) - takeLambdas({ it }, { } as (Nothing) -> Unit, { x: Int -> x }) - takeLambdas({ it }, { } as (Int) -> Unit, { } as (Nothing) -> Unit) + takeLambdas({ it }, { x: Int -> }, { x: Nothing -> x }) + takeLambdas({ it }, { } as (Int) -> Unit, { x: Nothing -> x }) + takeLambdas({ it }, { } as (Nothing) -> Unit, { x: Int -> x }) + takeLambdas({ it }, { } as (Int) -> Unit, { } as (Nothing) -> Unit) // Inferring lambda parameter types by other specified lambda parameters; expected type is a functional type with type variables in parameter types; dependent type parameters takeLambdasWithDirectlyDependentTypeParameters({ it }, { it }, { x: Int -> x }) diff --git a/compiler/testData/diagnostics/tests/inference/kt45461.diag.txt b/compiler/testData/diagnostics/tests/inference/kt45461.diag.txt new file mode 100644 index 00000000000..7662ff61537 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt45461.diag.txt @@ -0,0 +1,6 @@ +/kt45461.kt:6:25: warning: parameter 'foo' is never used + fun takeFoo(foo: Foo) {} + ^ +/kt45461.kt:11:19: warning: type argument for a type parameter S can't be inferred because it's upper bounded by incompatible types: String, Int. This will become an error in Kotlin 1.8 + Bar().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 + ^ diff --git a/compiler/testData/diagnostics/tests/inference/kt45461.kt b/compiler/testData/diagnostics/tests/inference/kt45461.kt new file mode 100644 index 00000000000..4e405cc242e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt45461.kt @@ -0,0 +1,11 @@ +// RENDER_DIAGNOSTICS_FULL_TEXT +class Foo + +class Bar { + fun takeFoo(foo: Foo) {} +} + +fun main() { + val foo = Foo() + Bar().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/kt45461.txt b/compiler/testData/diagnostics/tests/inference/kt45461.txt new file mode 100644 index 00000000000..3b7c911b916 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt45461.txt @@ -0,0 +1,18 @@ +package + +public fun main(): kotlin.Unit + +public final class Bar { + public constructor Bar() + 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 fun takeFoo(/*0*/ foo: Foo): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class Foo { + public constructor Foo() + 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/inference/kt48765.diag.txt b/compiler/testData/diagnostics/tests/inference/kt48765.diag.txt new file mode 100644 index 00000000000..b4ab4c5d19d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt48765.diag.txt @@ -0,0 +1,15 @@ +/kt48765.kt:5:44: warning: parameter 'x1' is never used + fun > foo(x1: T2, x2: T1) {} + ^ +/kt48765.kt:5:52: warning: parameter 'x2' is never used + fun > foo(x1: T2, x2: T1) {} + ^ +/kt48765.kt:9:13: warning: type argument for a type parameter T can't be inferred because it's upper bounded by incompatible types: String, Number. This will become an error in Kotlin 1.8 + B().foo(x, foo()) + ^ +/kt48765.kt:13:9: warning: 'String' is a final type, and thus a value of the type parameter is predetermined +fun foo(): T { + ^ +/kt48765.kt:14:15: warning: unchecked cast: String to T + return "" as T // this cast is safe because String is final. + ^ diff --git a/compiler/testData/diagnostics/tests/inference/kt48765.kt b/compiler/testData/diagnostics/tests/inference/kt48765.kt new file mode 100644 index 00000000000..dfa53d701e2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt48765.kt @@ -0,0 +1,17 @@ +// RENDER_DIAGNOSTICS_FULL_TEXT +open class A {} +class B { + fun > foo(x1: T2, x2: T1) {} +} +class C(val x: T, val y: T2) { + fun test() { + B().foo(x, foo()) + } +} +open class D: A() +fun String> foo(): T { + return "" as T // this cast is safe because String is final. +} +fun main() { + C(D(), 10.5).test() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/kt48765.txt b/compiler/testData/diagnostics/tests/inference/kt48765.txt new file mode 100644 index 00000000000..0feda840d71 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt48765.txt @@ -0,0 +1,36 @@ +package + +public fun foo(): T +public fun main(): kotlin.Unit + +public open class A { + public constructor 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 B { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun > foo(/*0*/ x1: T2, /*1*/ x2: T1): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class C { + public constructor C(/*0*/ x: T, /*1*/ y: T2) + public final val x: T + public final val y: T2 + 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 fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class D : A { + public constructor D() + 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/inference/kt48935.diag.txt b/compiler/testData/diagnostics/tests/inference/kt48935.diag.txt new file mode 100644 index 00000000000..649d7d5bc27 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt48935.diag.txt @@ -0,0 +1,7 @@ +/kt48935.kt:7:35: warning: parameter 'func' is never used +fun exampleGenericFunction(func: V) where T: Base, V: (T) -> Unit { + ^ +/kt48935.kt:13:5: warning: type argument for a type parameter T can't be inferred because it's upper bounded by incompatible types: Base, DoesNotImplementBase. This will become an error in Kotlin 1.8 + exampleGenericFunction(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied + ^ + diff --git a/compiler/testData/diagnostics/tests/inference/kt48935.kt b/compiler/testData/diagnostics/tests/inference/kt48935.kt new file mode 100644 index 00000000000..11c67aa1443 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt48935.kt @@ -0,0 +1,13 @@ +// RENDER_DIAGNOSTICS_FULL_TEXT +interface Base + +class DoesNotImplementBase + +fun exampleGenericFunction(func: V) where T: Base, V: (T) -> Unit { + +} + +fun main() { + val func: (DoesNotImplementBase) -> Unit = { } + exampleGenericFunction(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/kt48935.txt b/compiler/testData/diagnostics/tests/inference/kt48935.txt new file mode 100644 index 00000000000..cd6c9b82779 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt48935.txt @@ -0,0 +1,17 @@ +package + +public fun kotlin.Unit> exampleGenericFunction(/*0*/ func: V): kotlin.Unit +public fun main(): kotlin.Unit + +public interface Base { + 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 DoesNotImplementBase { + public constructor DoesNotImplementBase() + 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/inference/kt49661.diag.txt b/compiler/testData/diagnostics/tests/inference/kt49661.diag.txt new file mode 100644 index 00000000000..9c8443bfaa6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt49661.diag.txt @@ -0,0 +1,4 @@ +/kt49661.kt:11:5: warning: type argument for a type parameter T can't be inferred because it's upper bounded by incompatible types: Foo, Int. This will become an error in Kotlin 1.8 + f { g() } + ^ + diff --git a/compiler/testData/diagnostics/tests/inference/kt49661.kt b/compiler/testData/diagnostics/tests/inference/kt49661.kt new file mode 100644 index 00000000000..3a18c6b377d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt49661.kt @@ -0,0 +1,11 @@ +// RENDER_DIAGNOSTICS_FULL_TEXT +open class Foo +inline fun g(): T? = null + +inline fun f(block: ()->R?): R? { + return block() +} + +fun main() { + f { g() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/kt49661.txt b/compiler/testData/diagnostics/tests/inference/kt49661.txt new file mode 100644 index 00000000000..3495a391d42 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/kt49661.txt @@ -0,0 +1,12 @@ +package + +public inline fun f(/*0*/ block: () -> R?): R? +public inline fun g(): T? +public fun main(): kotlin.Unit + +public open class Foo { + public constructor Foo() + 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/inference/selectOfLambdaWithExtension.kt b/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtension.kt index 5815056609c..1dc1c78bba5 100644 --- a/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtension.kt +++ b/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtension.kt @@ -14,7 +14,7 @@ val a1: A = select( { a: Int -> myPrint(a + this.length + 2) } ) -val a2 = select( +val a2 = select( { a: Int -> myPrint(a + this.length + 1) }, fun CharSequence.(a: Int) { myPrint(a + this.length + 2) }, { a: Int -> myPrint(a + this.length + 3) } diff --git a/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionDisabled.kt b/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionDisabled.kt index 549d54327fa..b054460a767 100644 --- a/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionDisabled.kt +++ b/compiler/testData/diagnostics/tests/inference/selectOfLambdaWithExtensionDisabled.kt @@ -14,7 +14,7 @@ val a1: A = select( { a: Int -> myPrint(a + this.length + 2) } ) -val a2 = select( +val a2 = select( { a: Int -> myPrint(a + this.length + 1) }, fun CharSequence.(a: Int) { myPrint(a + this.length + 2) }, { a: Int -> myPrint(a + this.length + 3) } diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt index cb44030c595..ffe2855f8f9 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt @@ -13,7 +13,7 @@ fun testElvis(a: Int?, b: Int?) { if (a != null) { doInt(b ?: a) } - doList(getList() ?: emptyListOfA()) //should be an error + doList(getList() ?: emptyListOfA()) //should be an error doList(getList() ?: strangeList { doInt(it) }) //lambda was not analyzed } diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt index 52d11c382ca..645cb0bf721 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt @@ -12,7 +12,7 @@ fun emptyNullableListOfA(): List? = null //------------------------------- fun testExclExcl() { - doList(emptyNullableListOfA()!!) //should be an error here + doList(emptyNullableListOfA()!!) //should be an error here val l: List = id(emptyNullableListOfA()!!) doList(strangeNullableList { doInt(it) }!!) //lambda should be analyzed (at completion phase) diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 9f5e643feaf..f10638f4cd6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -13840,6 +13840,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/kt40396.kt"); } + @Test + @TestMetadata("kt45461.kt") + public void testKt45461() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt45461.kt"); + } + @Test @TestMetadata("kt46515.kt") public void testKt46515() throws Exception { @@ -13852,6 +13858,18 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/kt47316.kt"); } + @Test + @TestMetadata("kt48765.kt") + public void testKt48765() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt48765.kt"); + } + + @Test + @TestMetadata("kt48935.kt") + public void testKt48935() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt48935.kt"); + } + @Test @TestMetadata("kt49658.kt") public void testKt49658() throws Exception { @@ -13864,6 +13882,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/inference/kt49658Strict.kt"); } + @Test + @TestMetadata("kt49661.kt") + public void testKt49661() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/kt49661.kt"); + } + @Test @TestMetadata("kt6175.kt") public void testKt6175() throws Exception {