From b2299ed19f9a0fbc099f056893ca6fd7e77f8bbb Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Wed, 29 Nov 2017 11:10:51 +0300 Subject: [PATCH] [NI] Fix testdata after introducing `DefinitelyNotNull` types --- .../multipleBoundsMemberScope/simple.kt | 2 +- .../capturedTypeWithPlatformSupertype.kt | 17 +++++++++++ .../capturedTypeWithPlatformSupertype.txt | 29 +++++++++++++++++++ .../generics/nullability/functionalBound.kt | 6 ++-- .../tests/generics/nullability/smartCasts.kt | 8 ++--- .../generics/nullability/smartCastsOnThis.kt | 12 ++++---- .../nullability/smartCastsValueArgument.kt | 14 ++++----- .../tests/generics/nullability/tpInBounds.kt | 2 +- .../generics/nullability/useAsReceiver.kt | 2 +- .../tests/j+k/collectorInference.kt | 2 +- .../nullAssertOnTypeWithNullableUpperBound.kt | 2 +- .../specialConstructions/constantsInIf.kt | 2 +- .../checkers/DiagnosticsTestGenerated.java | 6 ++++ .../DiagnosticsUsingJavacTestGenerated.java | 6 ++++ 14 files changed, 84 insertions(+), 26 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.kt create mode 100644 compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.txt diff --git a/compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/simple.kt b/compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/simple.kt index cceef511679..3a76b1ca50c 100644 --- a/compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/simple.kt +++ b/compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/simple.kt @@ -9,6 +9,6 @@ interface B: A fun test(x: T) where T : C?, T : B? { x?.foo() if (x != null) { - x.foo() + x.foo() } } diff --git a/compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.kt b/compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.kt new file mode 100644 index 00000000000..fe61ad8e7a8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.kt @@ -0,0 +1,17 @@ +// FILE: First.java + +public class First { + public static void bind(First first) {} +} + +// FILE: SubFirst.java + +public class SubFirst extends First {} + +// FILE: test.kt + +interface Sample + +fun test(s: SubFirst<*>) { + First.bind(s) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.txt b/compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.txt new file mode 100644 index 00000000000..8aff7524d31 --- /dev/null +++ b/compiler/testData/diagnostics/tests/generics/nullability/capturedTypeWithPlatformSupertype.txt @@ -0,0 +1,29 @@ +package + +public fun test(/*0*/ s: SubFirst<*>): kotlin.Unit + +public open class First { + public constructor First() + 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 bind(/*0*/ first: First!): 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 : First { + public constructor SubFirst() + 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 bind(/*0*/ first: First!): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/generics/nullability/functionalBound.kt b/compiler/testData/diagnostics/tests/generics/nullability/functionalBound.kt index 33be58312e4..5b5fcac8443 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/functionalBound.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/functionalBound.kt @@ -1,14 +1,14 @@ // !WITH_NEW_INFERENCE fun Unit)?> foo(x: E, y: T) { if (x != null) { - y(x) + y(x) } if (y != null) { - y(x) + y(x) } if (x != null && y != null) { - y(x) + y(x) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/nullability/smartCasts.kt b/compiler/testData/diagnostics/tests/generics/nullability/smartCasts.kt index d47c0e27222..bf66a69ee2f 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/smartCasts.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/smartCasts.kt @@ -12,13 +12,13 @@ fun foo(x: T) { if (x != null) { if (x != null) {} - x.length + x.length x?.length - x.bar1() + x.bar1() x.bar2() - x.bar3() - x.bar4() + x.bar3() + x.bar4() x?.bar1() diff --git a/compiler/testData/diagnostics/tests/generics/nullability/smartCastsOnThis.kt b/compiler/testData/diagnostics/tests/generics/nullability/smartCastsOnThis.kt index 671ecd63de0..2cf4d6f80ab 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/smartCastsOnThis.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/smartCastsOnThis.kt @@ -11,13 +11,13 @@ fun T.foo() { if (this != null) { if (this != null) {} - length + length this?.length - bar1() + bar1() bar2() - bar3() - bar4() + bar3() + bar4() this?.bar1() @@ -29,8 +29,8 @@ fun T.foo() { length this?.length - bar1() + bar1() bar2() - bar3() + bar3() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.kt b/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.kt index 40cfc6d1fd9..61c24054112 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/smartCastsValueArgument.kt @@ -11,12 +11,12 @@ fun foo(x: T) { if (x != null) { if (x != null) {} - y1 = x + y1 = x y2 = x - bar1(x) - bar1(x) - bar2(x) + bar1(x) + bar1(x) + bar2(x) bar3(x) } @@ -40,9 +40,9 @@ fun foo(x: T) { if (1 == 1) { val y = x!! - bar1(x) - bar1(x) - bar2(x) + bar1(x) + bar1(x) + bar2(x) bar3(x) bar1(y) diff --git a/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt b/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt index 1990c56c330..fd2989b84c0 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/tpInBounds.kt @@ -30,7 +30,7 @@ class A { t = y if (y != null) { - t = y + t = y } if (tN != null) { diff --git a/compiler/testData/diagnostics/tests/generics/nullability/useAsReceiver.kt b/compiler/testData/diagnostics/tests/generics/nullability/useAsReceiver.kt index 14f8ee214e4..dd60e28621f 100644 --- a/compiler/testData/diagnostics/tests/generics/nullability/useAsReceiver.kt +++ b/compiler/testData/diagnostics/tests/generics/nullability/useAsReceiver.kt @@ -23,5 +23,5 @@ fun foo(x: T) { x.bar3() - x?.let { it.length } + x?.let { it.length } } diff --git a/compiler/testData/diagnostics/tests/j+k/collectorInference.kt b/compiler/testData/diagnostics/tests/j+k/collectorInference.kt index c5021a738fe..75e51dc97ec 100644 --- a/compiler/testData/diagnostics/tests/j+k/collectorInference.kt +++ b/compiler/testData/diagnostics/tests/j+k/collectorInference.kt @@ -9,6 +9,6 @@ import java.util.stream.Stream fun test(a: Stream) { a.collect(Collectors.toList()) checkType { _>() } // actually the inferred type is platform - a.collect(Collectors.toList()) checkType { _>() } + a.collect(Collectors.toList()) checkType { _>() } } diff --git a/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt b/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt index f43cfd17581..d8c27d1374f 100644 --- a/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt +++ b/compiler/testData/diagnostics/tests/nullableTypes/nullAssertOnTypeWithNullableUpperBound.kt @@ -10,6 +10,6 @@ fun T.testThis(): String { if (this != null) { return this!!.toString() } - return this!!.toString() + return this!!.toString() } diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/constantsInIf.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/constantsInIf.kt index cf98ecab0f7..4c04b0a633b 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/constantsInIf.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/constantsInIf.kt @@ -8,7 +8,7 @@ fun test() { 2 }) - bar(1 ?: 2) + bar(1 ?: 2) } fun bar(s: String) = s \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 09a36ea539d..0c706440ecd 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -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"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index d975eb8fa24..a42862f317b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -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");