[NI] Don't treat last labeled return expression in lambda specially
#KT-36251 Fixed
This commit is contained in:
Generated
+5
@@ -5978,6 +5978,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/delegateExpressionAsLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedExpressionWithLabeledReturnInsideLambda.kt")
|
||||
public void testDelegatedExpressionWithLabeledReturnInsideLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/delegatedExpressionWithLabeledReturnInsideLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differentDelegatedExpressions.kt")
|
||||
public void testDifferentDelegatedExpressions() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt");
|
||||
|
||||
+4
@@ -208,6 +208,10 @@ class KotlinResolutionCallbacksImpl(
|
||||
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
|
||||
if (expectedReturnType?.isUnit() == true || hasReturnWithoutExpression) return@let null // coercion to Unit
|
||||
|
||||
if (lambdaInfo.returnStatements.any { (expression, _) -> expression == lastExpression }) {
|
||||
return@let null
|
||||
}
|
||||
|
||||
// todo lastExpression can be if without else
|
||||
returnArgumentFound = true
|
||||
val lastExpressionType = trace.getType(lastExpression)
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
class Delegate<T>
|
||||
|
||||
operator fun <T> Delegate<T>.getValue(thisRef: Any?, property: kotlin.reflect.KProperty<*>): T = TODO()
|
||||
|
||||
fun <K> createDelegate(f: () -> K): Delegate<K> = TODO()
|
||||
|
||||
fun test() {
|
||||
val bar: () -> String by createDelegate {
|
||||
return@createDelegate { "str" }
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ K> createDelegate(/*0*/ f: () -> K): Delegate<K>
|
||||
public fun test(): kotlin.Unit
|
||||
public operator fun </*0*/ T> Delegate<T>.getValue(/*0*/ thisRef: kotlin.Any?, /*1*/ property: kotlin.reflect.KProperty<*>): T
|
||||
|
||||
public final class Delegate</*0*/ T> {
|
||||
public constructor Delegate</*0*/ 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
|
||||
}
|
||||
@@ -5985,6 +5985,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/delegateExpressionAsLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedExpressionWithLabeledReturnInsideLambda.kt")
|
||||
public void testDelegatedExpressionWithLabeledReturnInsideLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/delegatedExpressionWithLabeledReturnInsideLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differentDelegatedExpressions.kt")
|
||||
public void testDifferentDelegatedExpressions() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt");
|
||||
|
||||
Generated
+5
@@ -5980,6 +5980,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/delegateExpressionAsLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("delegatedExpressionWithLabeledReturnInsideLambda.kt")
|
||||
public void testDelegatedExpressionWithLabeledReturnInsideLambda() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/delegatedExpressionWithLabeledReturnInsideLambda.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("differentDelegatedExpressions.kt")
|
||||
public void testDifferentDelegatedExpressions() throws Exception {
|
||||
runTest("compiler/testData/diagnostics/tests/delegatedProperty/inference/differentDelegatedExpressions.kt");
|
||||
|
||||
Reference in New Issue
Block a user