Fix KT-10805 for 'when'.

This commit is contained in:
Dmitry Petrov
2016-01-27 17:07:03 +03:00
parent 9db3440e72
commit c5fd496cc9
4 changed files with 52 additions and 1 deletions
@@ -179,7 +179,7 @@ class PatternMatchingTypingVisitor internal constructor(facade: ExpressionTyping
val entryExpression = whenEntry.expression ?: continue
val entryTypeInfo = BindingContextUtils.getRecordedTypeInfo(entryExpression, bindingContext) ?:
throw AssertionError("When entry was not processed")
continue
val entryType = entryTypeInfo.type
val entryDataFlowInfo =
@@ -0,0 +1,37 @@
val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>test1<!> = when {
true -> { <!TYPE_MISMATCH!>{ true }<!> }
else -> TODO()
}
val test1a: () -> Boolean = when {
true -> { { true } }
else -> TODO()
}
val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>test2<!> = when {
true -> { <!TYPE_MISMATCH!>{ true }<!> }
else -> when {
true -> { <!TYPE_MISMATCH!>{ true }<!> }
else -> TODO()
}
}
val test2a: () -> Boolean = when {
true -> { { true } }
else -> when {
true -> { <!TYPE_MISMATCH!>{ true }<!> } // TODO
else -> TODO()
}
}
val <!IMPLICIT_NOTHING_PROPERTY_TYPE!>test3<!> = when {
true -> { <!TYPE_MISMATCH!>{ true }<!> }
true -> { <!TYPE_MISMATCH!>{ true }<!> }
else -> TODO()
}
val test3a: () -> Boolean = when {
true -> { { true } }
true -> { { true } }
else -> TODO()
}
@@ -0,0 +1,8 @@
package
public val test1: kotlin.Nothing
public val test1a: () -> kotlin.Boolean
public val test2: kotlin.Nothing
public val test2a: () -> kotlin.Boolean
public val test3: kotlin.Nothing
public val test3a: () -> kotlin.Boolean
@@ -18869,6 +18869,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/when/WhenTypeDisjunctions.kt");
doTest(fileName);
}
@TestMetadata("whenWithNothingAndLambdas.kt")
public void testWhenWithNothingAndLambdas() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/when/whenWithNothingAndLambdas.kt");
doTest(fileName);
}
}
}