Regression: correct smart cast from Type? to Type!
This commit is contained in:
+2
-2
@@ -300,8 +300,8 @@ internal class DelegatingDataFlowInfo private constructor(
|
|||||||
val toDelete = newTypeInfo()
|
val toDelete = newTypeInfo()
|
||||||
for (value in typeInfo.keys()) {
|
for (value in typeInfo.keys()) {
|
||||||
for (type in typeInfo[value]) {
|
for (type in typeInfo[value]) {
|
||||||
// Remove original type and for not flexible type also all its supertypes (see also KT-10666)
|
// Remove original type (see also KT-10666)
|
||||||
if (if (value.type.isFlexible()) value.type == type else value.type.isSubtypeOf(type)) {
|
if (value.type == type) {
|
||||||
toDelete.put(value, 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);
|
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")
|
@TestMetadata("unnecessary.kt")
|
||||||
public void testUnnecessary() throws Exception {
|
public void testUnnecessary() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/unnecessary.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/varnotnull/unnecessary.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user