Move and fix tests on typeEnhancement with TYPE_USE annotations

This commit is contained in:
Denis Zharkov
2016-03-16 12:51:08 +03:00
parent a644dd3ae9
commit e96024017f
13 changed files with 84 additions and 52 deletions
@@ -46,4 +46,43 @@ public class ForeignJava8AnnotationsTestGenerated extends AbstractForeignJava8An
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/eclipse.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class TypeEnhancement extends AbstractForeignJava8AnnotationsTest {
public void testAllFilesPresentInTypeEnhancement() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("annotatedTypeArguments.kt")
public void testAnnotatedTypeArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/annotatedTypeArguments.kt");
doTest(fileName);
}
@TestMetadata("methodWithTypeParameter.kt")
public void testMethodWithTypeParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/methodWithTypeParameter.kt");
doTest(fileName);
}
@TestMetadata("returnTypeDifferentConstructor.kt")
public void testReturnTypeDifferentConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeDifferentConstructor.kt");
doTest(fileName);
}
@TestMetadata("returnTypeOverrideInKotlin.kt")
public void testReturnTypeOverrideInKotlin() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/returnTypeOverrideInKotlin.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/foreignAnnotationsJava8/tests/typeEnhancement/simple.kt");
doTest(fileName);
}
}
} }
@@ -1,6 +1,6 @@
// FILE: AnnotatedTypeArguments.java // FILE: AnnotatedTypeArguments.java
import org.jetbrains.annotations.*; import org.checkerframework.checker.nullness.qual.*;
interface P<X, Y> {} interface P<X, Y> {}
interface L<T> {} interface L<T> {}
@@ -16,7 +16,7 @@ class AnnotatedTypeArguments {
// some complicated type tree // some complicated type tree
// return type and argument's type differ only by nullability of outermost type // return type and argument's type differ only by nullability of outermost type
@Nullable @Nullable
L<P<@NotNull L<@Nullable String>, @NotNull S<?>>> foo(@NotNull L<P<@NotNull L<@Nullable String>, @NotNull S<?>>> x) {return null;} L<P<@NonNull L<@Nullable String>, @NonNull S<?>>> foo(@NonNull L<P<@NonNull L<@Nullable String>, @NonNull S<?>>> x) {return null;}
} }
class C extends B { class C extends B {
@@ -26,13 +26,13 @@ class AnnotatedTypeArguments {
class D1 extends C { class D1 extends C {
// signature should be the same as in A, but annotated String-type should be platform // signature should be the same as in A, but annotated String-type should be platform
L<P<L<@NotNull String>, S<?>>> foo(L<P<L<@NotNull String>, S<?>>> x) {return null;} L<P<L<@NonNull String>, S<?>>> foo(L<P<L<@NonNull String>, S<?>>> x) {return null;}
} }
class D2 extends C { class D2 extends C {
// return type refined to not-nullable // return type refined to not-nullable
// argument type here same as in A except outermost type (it becomes flexible because of conflict) // argument type here same as in A except outermost type (it becomes flexible because of conflict)
@NotNull @NonNull
L<P<L<String>, S<?>>> foo(@Nullable L<P<L<String>, S<?>>> x) {return null;} L<P<L<String>, S<?>>> foo(@Nullable L<P<L<String>, S<?>>> x) {return null;}
} }
} }
@@ -17,7 +17,7 @@ public/*package*/ open class AnnotatedTypeArguments {
public/*package*/ open inner class B : AnnotatedTypeArguments.A { public/*package*/ open inner class B : AnnotatedTypeArguments.A {
public/*package*/ constructor B() public/*package*/ constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@org.jetbrains.annotations.Nullable() public/*package*/ open override /*1*/ fun foo(/*0*/ @org.jetbrains.annotations.NotNull() x: L<P<L<kotlin.String?>, S<*>>!>): L<P<L<kotlin.String?>, S<*>>!>? @org.checkerframework.checker.nullness.qual.Nullable() public/*package*/ open override /*1*/ fun foo(/*0*/ @org.checkerframework.checker.nullness.qual.NonNull() x: L<P<L<kotlin.String?>, S<*>>!>): L<P<L<kotlin.String?>, S<*>>!>?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -41,7 +41,7 @@ public/*package*/ open class AnnotatedTypeArguments {
public/*package*/ open inner class D2 : AnnotatedTypeArguments.C { public/*package*/ open inner class D2 : AnnotatedTypeArguments.C {
public/*package*/ constructor D2() public/*package*/ constructor D2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(/*0*/ @org.jetbrains.annotations.Nullable() x: L<P<L<kotlin.String?>, S<*>>!>!): L<P<L<kotlin.String?>, S<*>>!> @org.checkerframework.checker.nullness.qual.NonNull() public/*package*/ open override /*1*/ fun foo(/*0*/ @org.checkerframework.checker.nullness.qual.Nullable() x: L<P<L<kotlin.String?>, S<*>>!>!): L<P<L<kotlin.String?>, S<*>>!>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -1,6 +1,6 @@
// FILE: Outer.java // FILE: Outer.java
import org.jetbrains.annotations.*; import org.checkerframework.checker.nullness.qual.*;
interface X<T> {} interface X<T> {}
interface Y<T> {} interface Y<T> {}
@@ -15,7 +15,7 @@ class Outer {
class B extends A { class B extends A {
// OK, non-platform types // OK, non-platform types
@Override @Override
<T1, T2> @NotNull T2 foo(@Nullable T1 x) { return null; } <T1, T2> @NonNull T2 foo(@Nullable T1 x) { return null; }
// Parameter type is fully non-flexible (OK) // Parameter type is fully non-flexible (OK)
// Return type is `X<R!>?`. // Return type is `X<R!>?`.
@@ -23,7 +23,7 @@ class Outer {
// so type enhancing happens only for outermost type. // so type enhancing happens only for outermost type.
// TODO: We should properly compare equality with specific local equality axioms (as when calculating overriden descriptors) // TODO: We should properly compare equality with specific local equality axioms (as when calculating overriden descriptors)
@Override @Override
<R> @Nullable X<@Nullable R> bar(@NotNull Y<@NotNull R> x) { return null; } <R> @Nullable X<@Nullable R> bar(@NonNull Y<@NonNull R> x) { return null; }
} }
class C extends B { class C extends B {
@@ -41,11 +41,11 @@ class Outer {
// Return type is not-nullable, covariantly overridden, OK // Return type is not-nullable, covariantly overridden, OK
// Parameter type is flexible, because of conflict with supertype, OK // Parameter type is flexible, because of conflict with supertype, OK
@Override @Override
@NotNull @NonNull
<U, W> W foo(@Nullable U x) { return null; } <U, W> W foo(@Nullable U x) { return null; }
@Override @Override
<F> @NotNull X<@NotNull F> bar(@Nullable Y<@Nullable F> x) { return null; } <F> @NonNull X<@NonNull F> bar(@Nullable Y<@Nullable F> x) { return null; }
} }
} }
@@ -17,9 +17,9 @@ public/*package*/ open class Outer {
public/*package*/ open inner class B : Outer.A { public/*package*/ open inner class B : Outer.A {
public/*package*/ constructor B() public/*package*/ constructor B()
@java.lang.Override() public/*package*/ open override /*1*/ fun </*0*/ R : kotlin.Any!> bar(/*0*/ @org.jetbrains.annotations.NotNull() x: Y<R>): X<R!>? @java.lang.Override() public/*package*/ open override /*1*/ fun </*0*/ R : kotlin.Any!> bar(/*0*/ @org.checkerframework.checker.nullness.qual.NonNull() x: Y<R>): X<R!>?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@java.lang.Override() public/*package*/ open override /*1*/ fun </*0*/ T1 : kotlin.Any!, /*1*/ T2 : kotlin.Any!> foo(/*0*/ @org.jetbrains.annotations.Nullable() x: T1?): T2 @java.lang.Override() public/*package*/ open override /*1*/ fun </*0*/ T1 : kotlin.Any!, /*1*/ T2 : kotlin.Any!> foo(/*0*/ @org.checkerframework.checker.nullness.qual.Nullable() x: T1?): T2
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -35,9 +35,9 @@ public/*package*/ open class Outer {
public/*package*/ open inner class D : Outer.C { public/*package*/ open inner class D : Outer.C {
public/*package*/ constructor D() public/*package*/ constructor D()
@java.lang.Override() public/*package*/ open override /*1*/ fun </*0*/ F : kotlin.Any!> bar(/*0*/ @org.jetbrains.annotations.Nullable() x: Y<F!>!): X<F!> @java.lang.Override() public/*package*/ open override /*1*/ fun </*0*/ F : kotlin.Any!> bar(/*0*/ @org.checkerframework.checker.nullness.qual.Nullable() x: Y<F!>!): X<F!>
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@java.lang.Override() @org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun </*0*/ U : kotlin.Any!, /*1*/ W : kotlin.Any!> foo(/*0*/ @org.jetbrains.annotations.Nullable() x: U?): W @java.lang.Override() @org.checkerframework.checker.nullness.qual.NonNull() public/*package*/ open override /*1*/ fun </*0*/ U : kotlin.Any!, /*1*/ W : kotlin.Any!> foo(/*0*/ @org.checkerframework.checker.nullness.qual.Nullable() x: U?): W
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -1,13 +1,13 @@
// FILE: Outer.java // FILE: Outer.java
import org.jetbrains.annotations.*; import org.checkerframework.checker.nullness.qual.*;
interface Base<T> {} interface Base<T> {}
interface Derived<E> extends Base<E> {} interface Derived<E> extends Base<E> {}
class Outer { class Outer {
class A { class A {
@Nullable Base<@NotNull String> foo() { return null; } @Nullable Base<@NonNull String> foo() { return null; }
} }
class B extends A { class B extends A {
@@ -17,7 +17,7 @@ class Outer {
class C extends A { class C extends A {
@Override @Override
@NotNull Base<String> foo() {} @NonNull Base<String> foo() {}
} }
class D extends A { class D extends A {
@@ -27,11 +27,11 @@ class Outer {
class E extends A { class E extends A {
@Override @Override
@NotNull Derived<String> foo() {} @NonNull Derived<String> foo() {}
} }
class F extends A { class F extends A {
@Override @Override
@NotNull Derived<@NotNull String> foo() {} @NonNull Derived<@NonNull String> foo() {}
} }
} }
@@ -9,7 +9,7 @@ public/*package*/ open class Outer {
public/*package*/ open inner class A { public/*package*/ open inner class A {
public/*package*/ constructor A() public/*package*/ constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@org.jetbrains.annotations.Nullable() public/*package*/ open fun foo(): Base<kotlin.String>? @org.checkerframework.checker.nullness.qual.Nullable() public/*package*/ open fun foo(): Base<kotlin.String>?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -25,7 +25,7 @@ public/*package*/ open class Outer {
public/*package*/ open inner class C : Outer.A { public/*package*/ open inner class C : Outer.A {
public/*package*/ constructor C() public/*package*/ constructor C()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@java.lang.Override() @org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(): Base<kotlin.String> @java.lang.Override() @org.checkerframework.checker.nullness.qual.NonNull() public/*package*/ open override /*1*/ fun foo(): Base<kotlin.String>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -41,7 +41,7 @@ public/*package*/ open class Outer {
public/*package*/ open inner class E : Outer.A { public/*package*/ open inner class E : Outer.A {
public/*package*/ constructor E() public/*package*/ constructor E()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@java.lang.Override() @org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(): Derived<kotlin.String!> @java.lang.Override() @org.checkerframework.checker.nullness.qual.NonNull() public/*package*/ open override /*1*/ fun foo(): Derived<kotlin.String!>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -49,7 +49,7 @@ public/*package*/ open class Outer {
public/*package*/ open inner class F : Outer.A { public/*package*/ open inner class F : Outer.A {
public/*package*/ constructor F() public/*package*/ constructor F()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@java.lang.Override() @org.jetbrains.annotations.NotNull() public/*package*/ open override /*1*/ fun foo(): Derived<kotlin.String!> @java.lang.Override() @org.checkerframework.checker.nullness.qual.NonNull() public/*package*/ open override /*1*/ fun foo(): Derived<kotlin.String!>
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -1,9 +1,9 @@
// FILE: A.java // FILE: A.java
import org.jetbrains.annotations.*; import org.checkerframework.checker.nullness.qual.*
public class A { public class A {
@Nullable Base<@NotNull String> foo() { return null; } @Nullable Base<@NonNull String> foo() { return null; }
} }
// FILE: a.kt // FILE: a.kt
@@ -6,7 +6,7 @@ public fun bar2(): Derived<kotlin.String?>
public open class A { public open class A {
public constructor A() public constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
@org.jetbrains.annotations.Nullable() public/*package*/ open fun foo(): Base<kotlin.String>? @org.checkerframework.checker.nullness.qual.Nullable() public/*package*/ open fun foo(): Base<kotlin.String>?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
} }
@@ -0,0 +1,8 @@
// FILE: A.java
import org.checkerframework.checker.nullness.qual.*;
import java.util.*;
class A {
List<@NonNull String> foo() {}
}
@@ -0,0 +1,9 @@
package
public/*package*/ open class A {
public/*package*/ constructor A()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public/*package*/ open fun foo(): kotlin.collections.(Mutable)List<kotlin.String>!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.checkers
import org.jetbrains.kotlin.test.MockLibraryUtil import org.jetbrains.kotlin.test.MockLibraryUtil
import java.io.File import java.io.File
abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() { abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsWithFullJdkTest() {
override fun getExtraClasspath(): List<File> { override fun getExtraClasspath(): List<File> {
return listOf(MockLibraryUtil.compileLibraryToJar( return listOf(MockLibraryUtil.compileLibraryToJar(
annotationsPath, annotationsPath,
@@ -13028,36 +13028,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), true); KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement"), Pattern.compile("^(.+)\\.kt$"), true);
} }
@TestMetadata("annotatedTypeArguments.kt")
public void testAnnotatedTypeArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/annotatedTypeArguments.kt");
doTest(fileName);
}
@TestMetadata("methodWithTypeParameter.kt")
public void testMethodWithTypeParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/methodWithTypeParameter.kt");
doTest(fileName);
}
@TestMetadata("overriddenExtensions.kt") @TestMetadata("overriddenExtensions.kt")
public void testOverriddenExtensions() throws Exception { public void testOverriddenExtensions() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/overriddenExtensions.kt");
doTest(fileName); doTest(fileName);
} }
@TestMetadata("returnTypeDifferentConstructor.kt")
public void testReturnTypeDifferentConstructor() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeDifferentConstructor.kt");
doTest(fileName);
}
@TestMetadata("returnTypeOverrideInKotlin.kt")
public void testReturnTypeOverrideInKotlin() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/returnTypeOverrideInKotlin.kt");
doTest(fileName);
}
@TestMetadata("saveAnnotationAfterSubstitution.kt") @TestMetadata("saveAnnotationAfterSubstitution.kt")
public void testSaveAnnotationAfterSubstitution() throws Exception { public void testSaveAnnotationAfterSubstitution() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt"); String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/platformTypes/typeEnhancement/saveAnnotationAfterSubstitution.kt");