diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt index 3342f9ae4c1..334ceb8c0d4 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallResolverUtil.kt @@ -52,21 +52,23 @@ public fun hasUnknownReturnType(type: KotlinType): Boolean { return ErrorUtils.containsErrorType(getReturnTypeForCallable(type)) } -public fun replaceReturnTypeByUnknown(type: KotlinType): KotlinType { +public fun replaceReturnTypeForCallable(type: KotlinType, given: KotlinType): KotlinType { assert(ReflectionTypes.isCallableType(type)) { "type $type is not a function or property" } val newArguments = Lists.newArrayList() newArguments.addAll(getParameterArgumentsOfCallableType(type)) - newArguments.add(TypeProjectionImpl(Variance.INVARIANT, DONT_CARE)) + newArguments.add(TypeProjectionImpl(Variance.INVARIANT, given)) return replaceTypeArguments(type, newArguments) } +public fun replaceReturnTypeByUnknown(type: KotlinType) = replaceReturnTypeForCallable(type, DONT_CARE) + private fun replaceTypeArguments(type: KotlinType, newArguments: List) = KotlinTypeImpl.create(type.getAnnotations(), type.getConstructor(), type.isMarkedNullable(), newArguments, type.getMemberScope()) private fun getParameterArgumentsOfCallableType(type: KotlinType) = type.getArguments().dropLast(1) -private fun getReturnTypeForCallable(type: KotlinType) = +fun getReturnTypeForCallable(type: KotlinType) = type.getArguments().last().getType() private fun CallableDescriptor.hasReturnTypeDependentOnUninferredParams(constraintSystem: ConstraintSystem): Boolean { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt index c555a7728a1..ae7e3899aa3 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/GenericCandidateResolver.kt @@ -210,7 +210,8 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes for (valueArgument in resolvedValueArgument.arguments) { valueArgument.getArgumentExpression()?.let { argumentExpression -> ArgumentTypeResolver.getFunctionLiteralArgumentIfAny(argumentExpression, context)?.let { functionLiteral -> - addConstraintForFunctionLiteral(functionLiteral, valueArgument, valueParameterDescriptor, constraintSystem, context) + addConstraintForFunctionLiteralArgument(functionLiteral, valueArgument, valueParameterDescriptor, constraintSystem, context, + resolvedCall.candidateDescriptor.returnType) } ArgumentTypeResolver.getCallableReferenceExpressionIfAny(argumentExpression, context)?.let { callableReference -> addConstraintForCallableReference(callableReference, valueArgument, valueParameterDescriptor, constraintSystem, context) @@ -223,12 +224,30 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes resolvedCall.setResultingSubstitutor(resultingSystem.resultingSubstitutor) } - private fun addConstraintForFunctionLiteral( + // See KT-5385 + // When literal returns T, and it's an argument of a function that also returns T, + // and we have some expected type Type, we can expected from literal to return Type + // Otherwise we do not care about literal's exact return type + private fun estimateLiteralReturnType( + context: CallCandidateResolutionContext<*>, + literalExpectedType: KotlinType, + ownerReturnType: KotlinType? + ) = if (!TypeUtils.noExpectedType(context.expectedType) && + ownerReturnType != null && + TypeUtils.isTypeParameter(ownerReturnType) && + KotlinBuiltIns.isFunctionOrExtensionFunctionType(literalExpectedType) && + getReturnTypeForCallable(literalExpectedType) == ownerReturnType) + + context.expectedType + else DONT_CARE + + private fun addConstraintForFunctionLiteralArgument( functionLiteral: KtFunction, valueArgument: ValueArgument, valueParameterDescriptor: ValueParameterDescriptor, constraintSystem: ConstraintSystem.Builder, - context: CallCandidateResolutionContext + context: CallCandidateResolutionContext, + argumentOwnerReturnType: KotlinType? ) { val argumentExpression = valueArgument.getArgumentExpression() ?: return @@ -269,8 +288,9 @@ class GenericCandidateResolver(private val argumentTypeResolver: ArgumentTypeRes return } } - val expectedTypeWithoutReturnType = replaceReturnTypeByUnknown(expectedType) - val newContext = context.replaceExpectedType(expectedTypeWithoutReturnType).replaceDataFlowInfo(dataFlowInfoForArgument) + val estimatedReturnType = estimateLiteralReturnType(context, effectiveExpectedType, argumentOwnerReturnType) + val expectedTypeWithEstimatedReturnType = replaceReturnTypeForCallable(expectedType, estimatedReturnType) + val newContext = context.replaceExpectedType(expectedTypeWithEstimatedReturnType).replaceDataFlowInfo(dataFlowInfoForArgument) .replaceContextDependency(INDEPENDENT) val type = argumentTypeResolver.getFunctionLiteralTypeInfo(argumentExpression, functionLiteral, newContext, RESOLVE_FUNCTION_ARGUMENTS).type constraintSystem.addSubtypeConstraint(type, effectiveExpectedTypeInSystem, position) diff --git a/compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt b/compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt new file mode 100644 index 00000000000..1bf020aeed2 --- /dev/null +++ b/compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt @@ -0,0 +1,12 @@ +class Foo(val s: String) +fun foo(): Foo? = Foo("OK") + +fun run(f: () -> T): T = f() + +val foo: Foo = run { + val x = foo() + if (x == null) throw Exception() + x +} + +fun box() = foo.s diff --git a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt index 2bf117dbd0f..c9d27ff6ac3 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/assignmentOperationInLambdaWithExpectedType.kt @@ -11,6 +11,6 @@ fun test(bal: Array) { val e: Unit = run { bar += 4 } - val f: Int = run { bar += 4 } + val f: Int = run { bar += 4 } } fun run(f: () -> T): T = f() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt b/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt index 759fecc30ed..c11fe4c9891 100644 --- a/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt +++ b/compiler/testData/diagnostics/tests/functionLiterals/return/SmartCastWithExplicitType.kt @@ -7,10 +7,10 @@ val a : (Int?) -> Int = l@ { fun let(f: (Int?) -> R): R = null!! -val b: Int = let { - if (it != null) return@let it +val b: Int = let { + if (it != null) return@let it 5 -} +} val c: Int = let { if (it != null) it else 5 diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt index 2a425761287..5cc30c98bd3 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt731.kt @@ -13,6 +13,6 @@ fun A.foo(x: (T)-> G): G { fun main(args: Array) { val a = A(1) - val t: String = a.foo({p -> p}) + val t: String = a.foo({p -> p}) checkSubtype(t) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.kt b/compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.kt new file mode 100644 index 00000000000..4c8af5f4b96 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.kt @@ -0,0 +1,12 @@ +interface Foo +fun foo(): Foo? = null + +fun run(f: () -> T): T = f() + +val foo: Foo = run { + run { + val x = foo() + if (x == null) throw Exception() + x + } +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.txt b/compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.txt new file mode 100644 index 00000000000..92911120b87 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.txt @@ -0,0 +1,11 @@ +package + +public val foo: Foo +public fun foo(): Foo? +public fun run(/*0*/ f: () -> T): T + +public interface 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/smartCasts/lambdaArgumentNoSubstitutedReturn.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentNoSubstitutedReturn.kt new file mode 100644 index 00000000000..fcb5ef96cc1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentNoSubstitutedReturn.kt @@ -0,0 +1,19 @@ +class Indexed(val x: T, val y: Int) + +class Value(val x: T) + +interface WithValue { + fun value(): Value +} + +class Singleton(val x: T) : WithValue { + override fun value() = Value(x) +} + +class WithValueIndexed(val f: () -> Value) : WithValue> { + override fun value() = Value(Indexed(f().x, 0)) +} + +fun Singleton.indexed(): WithValue> { + return WithValueIndexed { value() } +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentNoSubstitutedReturn.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentNoSubstitutedReturn.txt new file mode 100644 index 00000000000..afebd82ef62 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentNoSubstitutedReturn.txt @@ -0,0 +1,45 @@ +package + +public fun Singleton.indexed(): WithValue> + +public final class Indexed { + public constructor Indexed(/*0*/ x: T, /*1*/ y: kotlin.Int) + public final val x: T + public final val y: kotlin.Int + 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 Singleton : WithValue { + public constructor Singleton(/*0*/ x: T) + public final val x: 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 open override /*1*/ fun value(): Value +} + +public final class Value { + public constructor Value(/*0*/ x: T) + public final val x: 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 interface WithValue { + 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 value(): Value +} + +public final class WithValueIndexed : WithValue> { + public constructor WithValueIndexed(/*0*/ f: () -> Value) + public final val f: () -> Value + 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 open override /*1*/ fun value(): Value> +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt new file mode 100644 index 00000000000..f8e82cdd3f0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt @@ -0,0 +1,25 @@ +interface Foo +interface Bar : Foo + +fun foo(): Foo? = null +fun bar(): Bar? = null + +fun run(f: () -> T): T = f() + +val foo: Foo = run { + val x = bar() + if (x == null) throw Exception() + x +} + +val foofoo: Foo = run { + val x = foo() + if (x == null) throw Exception() + x +} + +val bar: Bar = run { + val x = foo() + if (x == null) throw Exception() + x +} diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.txt new file mode 100644 index 00000000000..07a813de15a --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.txt @@ -0,0 +1,20 @@ +package + +public val bar: Bar +public val foo: Foo +public val foofoo: Foo +public fun bar(): Bar? +public fun foo(): Foo? +public fun run(/*0*/ f: () -> T): T + +public interface Bar : 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 +} + +public interface 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/smartCasts/lambdaArgumentWithExpectedGenericType.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithExpectedGenericType.kt new file mode 100644 index 00000000000..b75e112ff9a --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithExpectedGenericType.kt @@ -0,0 +1,10 @@ +fun run(f: () -> T): T = f() + +class My(val y: T?) { + + fun get(): T = run { + val x = y + if (x == null) throw Exception() + x + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithExpectedGenericType.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithExpectedGenericType.txt new file mode 100644 index 00000000000..4c2cf620d0a --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithExpectedGenericType.txt @@ -0,0 +1,12 @@ +package + +public fun run(/*0*/ f: () -> T): T + +public final class My { + public constructor My(/*0*/ y: T?) + public final val y: T? + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun get(): T + 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/smartCasts/lambdaArgumentWithoutType.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutType.kt new file mode 100644 index 00000000000..a059db5e212 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutType.kt @@ -0,0 +1,22 @@ +// See KT-5385: no smart cast in a literal without given type arguments + +interface Foo +fun foo(): Foo? = null + +fun run(f: () -> T): T = f() + +val foo: Foo = run { + val x = foo() + if (x == null) throw Exception() + x +} + +// Basic non-lambda case + +fun repeat(arg: T): T = arg + +fun bar(): Foo { + val x = foo() + if (x == null) throw Exception() + return repeat(x) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutType.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutType.txt new file mode 100644 index 00000000000..e1f87b8f611 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutType.txt @@ -0,0 +1,13 @@ +package + +public val foo: Foo +public fun bar(): Foo +public fun foo(): Foo? +public fun repeat(/*0*/ arg: T): T +public fun run(/*0*/ f: () -> T): T + +public interface 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/smartCasts/lambdaArgumentWithoutTypeIf.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIf.kt new file mode 100644 index 00000000000..9c0ad1b3650 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIf.kt @@ -0,0 +1,15 @@ +// See also KT-7800 + +fun T.let(f: (T) -> R): R = f(this) + +fun foo(): Int { + val x: Int = 1.let { + val value: Int? = null + if (value == null) { + return@let 1 + } + + value // smart-cast should be here + } + return x +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIf.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIf.txt new file mode 100644 index 00000000000..3bece41fd06 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIf.txt @@ -0,0 +1,4 @@ +package + +public fun foo(): kotlin.Int +public fun T.let(/*0*/ f: (T) -> R): R diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.kt new file mode 100644 index 00000000000..6a603a324c8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.kt @@ -0,0 +1,14 @@ +// See also KT-7817 + +fun synchronized(lock: Any, block: () -> R): R = block() + +class My { + val test: String + get() = synchronized(this) { + var x: String? = "" + if (x == null) { + x = "s" + } + x + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.txt new file mode 100644 index 00000000000..669655d8fe6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.txt @@ -0,0 +1,11 @@ +package + +public fun synchronized(/*0*/ lock: kotlin.Any, /*1*/ block: () -> R): R + +public final class My { + public constructor My() + public final val test: kotlin.String + 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/smartCasts/lambdaArgumentWithoutTypeWhen.kt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeWhen.kt new file mode 100644 index 00000000000..61f568d4995 --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeWhen.kt @@ -0,0 +1,13 @@ +// See KT-10223 + +inline fun using(input: Any?, f: (Any?) -> T): T = f(input) + +val input: Any? = null + +// Error:(32, 24) Type inference failed. Expected type mismatch: inferred type is kotlin.Any? but kotlin.String was expected +val test4: String = using(input) { + when (it) { + is String -> it + else -> throw RuntimeException() + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeWhen.txt b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeWhen.txt new file mode 100644 index 00000000000..58dd4de774c --- /dev/null +++ b/compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeWhen.txt @@ -0,0 +1,5 @@ +package + +public val input: kotlin.Any? = null +public val test4: kotlin.String +public inline fun using(/*0*/ input: kotlin.Any?, /*1*/ f: (kotlin.Any?) -> T): T diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 66c48ae2d3d..2ceaf45751c 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -14700,6 +14700,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("doubleLambdaArgument.kt") + public void testDoubleLambdaArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/doubleLambdaArgument.kt"); + doTest(fileName); + } + @TestMetadata("elvisExclExcl.kt") public void testElvisExclExcl() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvisExclExcl.kt"); @@ -14880,6 +14886,48 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("lambdaArgumentNoSubstitutedReturn.kt") + public void testLambdaArgumentNoSubstitutedReturn() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentNoSubstitutedReturn.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaArgumentWithBoundWithoutType.kt") + public void testLambdaArgumentWithBoundWithoutType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithBoundWithoutType.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaArgumentWithExpectedGenericType.kt") + public void testLambdaArgumentWithExpectedGenericType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithExpectedGenericType.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaArgumentWithoutType.kt") + public void testLambdaArgumentWithoutType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutType.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaArgumentWithoutTypeIf.kt") + public void testLambdaArgumentWithoutTypeIf() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIf.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaArgumentWithoutTypeIfMerge.kt") + public void testLambdaArgumentWithoutTypeIfMerge() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeIfMerge.kt"); + doTest(fileName); + } + + @TestMetadata("lambdaArgumentWithoutTypeWhen.kt") + public void testLambdaArgumentWithoutTypeWhen() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaArgumentWithoutTypeWhen.kt"); + doTest(fileName); + } + @TestMetadata("lambdaCall.kt") public void testLambdaCall() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/lambdaCall.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java index a70001a8a20..9fad80ad570 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/generated/BlackBoxCodegenTestGenerated.java @@ -7270,6 +7270,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { doTest(fileName); } + @TestMetadata("lambdaArgumentWithoutType.kt") + public void testLambdaArgumentWithoutType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/lambdaArgumentWithoutType.kt"); + doTest(fileName); + } + @TestMetadata("nullSmartCast.kt") public void testNullSmartCast() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/smartCasts/nullSmartCast.kt");