[NI] Fix testdata after introducing DefinitelyNotNull types

This commit is contained in:
Mikhail Zarechenskiy
2017-11-29 11:10:51 +03:00
parent 9565b56b2a
commit b2299ed19f
14 changed files with 84 additions and 26 deletions
@@ -9,6 +9,6 @@ interface B: A
fun <T> test(x: T) where T : C?, T : B? {
x?.foo()
if (x != null) {
<!OI;DEBUG_INFO_SMARTCAST!>x<!><!NI;UNSAFE_CALL!>.<!>foo()
<!DEBUG_INFO_SMARTCAST!>x<!>.foo()
}
}
@@ -0,0 +1,17 @@
// FILE: First.java
public class First<T extends Sample> {
public static <D extends Sample> void bind(First<D> first) {}
}
// FILE: SubFirst.java
public class SubFirst<D extends Sample> extends First<D> {}
// FILE: test.kt
interface Sample
fun test(s: SubFirst<*>) {
First.bind(s)
}
@@ -0,0 +1,29 @@
package
public fun test(/*0*/ s: SubFirst<*>): kotlin.Unit
public open class First</*0*/ T : Sample!> {
public constructor First</*0*/ T : Sample!>()
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 open fun </*0*/ D : Sample!> bind(/*0*/ first: First<D!>!): kotlin.Unit
}
public interface Sample {
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 class SubFirst</*0*/ D : Sample!> : First<D!> {
public constructor SubFirst</*0*/ D : Sample!>()
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 open override /*1*/ /*fake_override*/ fun </*0*/ D : Sample!> bind(/*0*/ first: First<D!>!): kotlin.Unit
}
@@ -1,14 +1,14 @@
// !WITH_NEW_INFERENCE
fun <E : String?, T : ((CharSequence) -> Unit)?> foo(x: E, y: T) {
if (x != null) {
<!NI;UNSAFE_CALL, OI;UNSAFE_IMPLICIT_INVOKE_CALL!>y<!>(<!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>)
<!NI;UNSAFE_CALL, OI;UNSAFE_IMPLICIT_INVOKE_CALL!>y<!>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
if (y != null) {
<!NI;UNSAFE_CALL, OI;DEBUG_INFO_SMARTCAST!>y<!>(<!TYPE_MISMATCH!>x<!>)
<!DEBUG_INFO_SMARTCAST!>y<!>(<!TYPE_MISMATCH!>x<!>)
}
if (x != null && y != null) {
<!NI;UNSAFE_CALL, OI;DEBUG_INFO_SMARTCAST!>y<!>(<!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>)
<!DEBUG_INFO_SMARTCAST!>y<!>(<!DEBUG_INFO_SMARTCAST!>x<!>)
}
}
@@ -12,13 +12,13 @@ fun <T : CharSequence?> foo(x: T) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
<!OI;DEBUG_INFO_SMARTCAST!>x<!><!NI;UNSAFE_CALL!>.<!>length
<!DEBUG_INFO_SMARTCAST!>x<!>.length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
x.bar1()
<!NI;DEBUG_INFO_SMARTCAST!>x<!>.bar1()
x.bar2()
x<!NI;UNSAFE_CALL!>.<!><!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
<!OI;DEBUG_INFO_SMARTCAST!>x<!><!NI;UNSAFE_CALL!>.<!>bar4()
<!NI;DEBUG_INFO_SMARTCAST!>x<!>.<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
<!DEBUG_INFO_SMARTCAST!>x<!>.bar4()
x<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
@@ -11,13 +11,13 @@ fun <T : String?> T.foo() {
if (this != null) {
if (<!SENSELESS_COMPARISON!>this != null<!>) {}
<!NI;UNSAFE_CALL!>length<!>
<!NI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
bar1()
<!NI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
bar2()
<!NI;UNSAFE_CALL, OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
<!NI;UNSAFE_CALL!>bar4<!>()
<!NI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST, OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
<!NI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar4<!>()
this<!UNNECESSARY_SAFE_CALL!>?.<!>bar1()
@@ -29,8 +29,8 @@ fun <T : String?> T.foo() {
<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>length<!>
this<!UNNECESSARY_SAFE_CALL!>?.<!>length
bar1()
<!NI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>bar1<!>()
bar2()
<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
<!NI;DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST, OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
}
}
@@ -11,12 +11,12 @@ fun <T : CharSequence?> foo(x: T) {
if (x != null) {
if (<!SENSELESS_COMPARISON!>x != null<!>) {}
y1 = <!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>
y1 = <!DEBUG_INFO_SMARTCAST!>x<!>
y2 = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>x<!>
<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar1<!>(<!NI;TYPE_MISMATCH!>x<!>)
bar1<CharSequence>(<!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>)
bar2(<!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>)
<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar1<!>(<!NI;DEBUG_INFO_SMARTCAST!>x<!>)
bar1<CharSequence>(<!DEBUG_INFO_SMARTCAST!>x<!>)
bar2(<!DEBUG_INFO_SMARTCAST!>x<!>)
bar3(<!TYPE_MISMATCH!>x<!>)
}
@@ -40,9 +40,9 @@ fun <T : CharSequence?> foo(x: T) {
if (1 == 1) {
val y = x!!
<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar1<!>(<!NI;TYPE_MISMATCH!>x<!>)
bar1<CharSequence>(<!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>)
bar2(<!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>x<!>)
<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar1<!>(<!NI;DEBUG_INFO_SMARTCAST!>x<!>)
bar1<CharSequence>(<!DEBUG_INFO_SMARTCAST!>x<!>)
bar2(<!DEBUG_INFO_SMARTCAST!>x<!>)
bar3(<!TYPE_MISMATCH!>x<!>)
<!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar1<!>(y)
@@ -30,7 +30,7 @@ class A<T : CharSequence?, E1 : T, E2: T?> {
t = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>y<!>
if (y != null) {
t = <!NI;TYPE_MISMATCH, DEBUG_INFO_SMARTCAST!>y<!>
t = <!DEBUG_INFO_SMARTCAST!>y<!>
}
if (tN != null) {
@@ -23,5 +23,5 @@ fun <T : String?> foo(x: T) {
x<!NI;UNSAFE_CALL!>.<!><!OI;TYPE_INFERENCE_UPPER_BOUND_VIOLATED!>bar3<!>()
x?.let { it<!UNSAFE_CALL!>.<!>length }
x?.let { it<!OI;UNSAFE_CALL!>.<!>length }
}
@@ -9,6 +9,6 @@ import java.util.stream.Stream
fun test(a: Stream<String>) {
a.collect(Collectors.toList()) checkType { _<MutableList<String>>() }
// actually the inferred type is platform
a.collect(Collectors.toList()) checkType { <!NI;DEBUG_INFO_UNRESOLVED_WITH_TARGET, NI;UNRESOLVED_REFERENCE_WRONG_RECEIVER!>_<!><List<String?>>() }
a.collect(Collectors.toList()) checkType { _<List<String?>>() }
}
@@ -10,6 +10,6 @@ fun <T> T.testThis(): String {
if (this != null) {
return this<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>.toString()
}
<!NI;UNREACHABLE_CODE!>return<!> this!!<!NI;UNREACHABLE_CODE!>.toString()<!>
return this!!.toString()
}
@@ -8,7 +8,7 @@ fun test() {
<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!>
}<!>)
bar(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>)
bar(<!NI;TYPE_MISMATCH!><!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> ?: <!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>2<!><!>)
}
fun bar(s: String) = s
@@ -9237,6 +9237,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/generics/nullability"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("capturedTypeWithPlatformSupertype.kt")
public void testCapturedTypeWithPlatformSupertype() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.kt");
doTest(fileName);
}
@TestMetadata("declarationsBoundsViolation.kt")
public void testDeclarationsBoundsViolation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/nullability/declarationsBoundsViolation.kt");
@@ -9237,6 +9237,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/generics/nullability"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("capturedTypeWithPlatformSupertype.kt")
public void testCapturedTypeWithPlatformSupertype() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.kt");
doTest(fileName);
}
@TestMetadata("declarationsBoundsViolation.kt")
public void testDeclarationsBoundsViolation() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/nullability/declarationsBoundsViolation.kt");