Regression: correct smart cast from Type? to Type!

This commit is contained in:
Mikhail Glukhikh
2016-01-28 17:08:15 +03:00
parent 26a2319d7c
commit 5062ce2804
4 changed files with 38 additions and 2 deletions
@@ -300,8 +300,8 @@ internal class DelegatingDataFlowInfo private constructor(
val toDelete = newTypeInfo()
for (value in typeInfo.keys()) {
for (type in typeInfo[value]) {
// Remove original type and for not flexible type also all its supertypes (see also KT-10666)
if (if (value.type.isFlexible()) value.type == type else value.type.isSubtypeOf(type)) {
// Remove original type (see also KT-10666)
if (value.type == type) {
toDelete.put(value, type)
}
}
@@ -0,0 +1,16 @@
// FILE: J.java
class J {
static String foo() { return "abc"; }
}
// FILE: test.kt
fun bar() {
var v: String?
v = J.foo()
<!DEBUG_INFO_SMARTCAST!>v<!>.length
gav(<!DEBUG_INFO_SMARTCAST!>v<!>)
}
fun gav(v: String) = v
@@ -0,0 +1,14 @@
package
public fun bar(): kotlin.Unit
public fun gav(/*0*/ v: kotlin.String): kotlin.String
public/*package*/ open class J {
public/*package*/ constructor J()
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
// Static members
public/*package*/ open fun foo(): kotlin.String!
}
@@ -17435,6 +17435,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("toFlexibleType.kt")
public void testToFlexibleType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/toFlexibleType.kt");
doTest(fileName);
}
@TestMetadata("unnecessary.kt")
public void testUnnecessary() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/unnecessary.kt");