From 2f0f5528801b0578b741d6d45c2e6942c5afee64 Mon Sep 17 00:00:00 2001 From: Denis Zharkov Date: Thu, 16 Apr 2020 12:24:09 +0300 Subject: [PATCH] FIR: Adjust testData for spec tests: annotations --- .../annotation-classes/neg/1.fir.kt | 74 +++++++++++++++++++ .../annotations/type-annotations/neg/1.fir.kt | 16 ++++ .../type-annotations/neg/10.fir.kt | 35 +++++++++ .../type-annotations/neg/11.fir.kt | 37 ++++++++++ .../annotations/type-annotations/neg/2.fir.kt | 17 +++++ .../annotations/type-annotations/neg/3.fir.kt | 26 +++++++ .../annotations/type-annotations/neg/4.fir.kt | 16 ++++ .../annotations/type-annotations/neg/5.fir.kt | 21 ++++++ .../annotations/type-annotations/neg/6.fir.kt | 46 ++++++++++++ .../annotations/type-annotations/neg/7.fir.kt | 30 ++++++++ .../annotations/type-annotations/neg/8.fir.kt | 20 +++++ .../annotations/type-annotations/neg/9.fir.kt | 21 ++++++ 12 files changed, 359 insertions(+) create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/annotation-classes/neg/1.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/1.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/10.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/11.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/2.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/3.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/4.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/5.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/6.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/7.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/8.fir.kt create mode 100644 compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/9.fir.kt diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/annotation-classes/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/annotation-classes/neg/1.fir.kt new file mode 100644 index 00000000000..671ade28ab7 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/annotation-classes/neg/1.fir.kt @@ -0,0 +1,74 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, annotation-classes + * NUMBER: 1 + * DESCRIPTION: Annotation classes with forbidden `JvmOverloads` annotation on its constructor. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-25702 + */ + +// TESTCASE NUMBER: 2, 3, 4 +@Target(AnnotationTarget.CONSTRUCTOR) +annotation class Case12_1 + +@Target(AnnotationTarget.CONSTRUCTOR) +@Retention(AnnotationRetention.SOURCE) +@Repeatable +annotation class Case12_2 + +// TESTCASE NUMBER: 1 +annotation class Case1 @JvmOverloads constructor(val x: Int) + +// TESTCASE NUMBER: 2 +annotation class Case2 @[Case12_2 Case12_2 Case12_2 Case12_2 Case12_2 Case12_2 JvmOverloads Case12_1] constructor(x: Int = 10) + +// TESTCASE NUMBER: 3 +annotation class Case3 @Case12_2 @Case12_1 @Case12_2 @`JvmOverloads` @Case12_2 @Case12_2 constructor(x: Int = 10) + +// TESTCASE NUMBER: 4 +annotation class Case4 @Case12_2 @[Case12_2 Case12_2 Case12_2 Case12_2 Case12_2 Case12_2 JvmOverloads Case12_1] @Case12_2 @Case12_2 constructor(x: Int = 10) + +// TESTCASE NUMBER: 5 +annotation class Case5 @[JvmOverloads] constructor(val x: Int) + +// TESTCASE NUMBER: 6 +annotation class Case6 @JvmOverloads constructor() + +// TESTCASE NUMBER: 7 +annotation class Case7@JvmOverloads constructor() {} + +// TESTCASE NUMBER: 8 +annotation class Case8 @`JvmOverloads` constructor() + +// TESTCASE NUMBER: 9 +annotation class Case9 @JvmOverloads constructor(val x: Int) + +// TESTCASE NUMBER: 10 +annotation class Case10 @JvmOverloads constructor(val x: Int) + +// TESTCASE NUMBER: 11 +annotation class Case11 > @JvmOverloads constructor(val x: Int) + +// TESTCASE NUMBER: 12 +annotation class Case12 @JvmOverloads constructor(val x: Int) where T: Number + +// TESTCASE NUMBER: 13 +annotation class Case13 constructor(val x: Int) { + annotation class Case1 @JvmOverloads constructor(val x: Int) +} + +// TESTCASE NUMBER: 14 +annotation class Case14 @JvmOverloads constructor(val x: Int) { + annotation class Case1 constructor(val x: Int) +} + +// TESTCASE NUMBER: 15 +object Case15 { + annotation class Case15 @JvmOverloads constructor(val x: Int) +} + +// TESTCASE NUMBER: 16 +class Case16 { + annotation class Case16 @JvmOverloads constructor(val x: Int) +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/1.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/1.fir.kt new file mode 100644 index 00000000000..8672724c491 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/1.fir.kt @@ -0,0 +1,16 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 1 + * DESCRIPTION: Type annotations on return type with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +fun case_1(x: String): @Ann(unresolved_reference) String { + return x +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/10.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/10.fir.kt new file mode 100644 index 00000000000..6f7f2ec3e98 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/10.fir.kt @@ -0,0 +1,35 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 10 + * DESCRIPTION: Type annotations on a lambda type with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1, 2 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +/* + * TESTCASE NUMBER: 1 + * UNEXPECTED BEHAVIOUR + */ +fun case_1() { + val x: (Int) -> @Ann(unresolved_reference) Unit = {} // OK, no error in IDE and in the compiler +} + +/* + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + */ +fun case_2() { + val x: (@Ann(unresolved_reference) Int) -> Unit = { a: Int -> println(a) } // OK, no error in IDE and in the compiler +} + +// TESTCASE NUMBER: 3 +fun case_3() { + val x: (@Ann(unresolved_reference) Int) -> Unit = { a -> println(a) } // ERROR (if argument type isn't specified explicitly) +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/11.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/11.fir.kt new file mode 100644 index 00000000000..371451368f3 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/11.fir.kt @@ -0,0 +1,37 @@ +// !WITH_NEW_INFERENCE + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 11 + * DESCRIPTION: Type annotations with invalid target. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-28449 + */ + +// TESTCASE NUMBER: 1, 2, 3, 4, 5 +@Retention(AnnotationRetention.RUNTIME) +@Target(AnnotationTarget.PROPERTY_GETTER) +annotation class Ann(val x: Int) + +// TESTCASE NUMBER: 1 +abstract class Foo : @Ann(10) Any() + +// TESTCASE NUMBER: 2 +abstract class Bar + +// TESTCASE NUMBER: 3 +fun case_3(a: Any) { + if (a is @Ann(10) String) return +} + +// TESTCASE NUMBER: 4 +open class TypeToken + +val case_4 = object : TypeToken<@Ann(10) String>() {} + +// TESTCASE NUMBER: 5 +fun case_5(a: Any) { + a as @Ann(10) Int +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/2.fir.kt new file mode 100644 index 00000000000..d2ae23f36da --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/2.fir.kt @@ -0,0 +1,17 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 2 + * DESCRIPTION: Type annotations on supertypes with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +/* + * TESTCASE NUMBER: 1 + * UNEXPECTED BEHAVIOUR + */ +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +abstract class Foo : @Ann(unresolved_reference) Any() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/3.fir.kt new file mode 100644 index 00000000000..8687c58a2ae --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/3.fir.kt @@ -0,0 +1,26 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 3 + * DESCRIPTION: Type annotations on parameter types with unresolved reference in parameters. + * UNEXPECTED BEHAVIOUR + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1, 2, 3 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +// TESTCASE NUMBER: 1 +class Inv + +fun foo(i: Inv<@Ann(unresolved_reference) String>) {} + +// TESTCASE NUMBER: 2 +fun test(vararg a: @Ann(unresolved_reference) Any) {} + +// TESTCASE NUMBER: 3 +class A(a: @Ann(unresolved_reference) T) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/4.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/4.fir.kt new file mode 100644 index 00000000000..224b8898c90 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/4.fir.kt @@ -0,0 +1,16 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 4 + * DESCRIPTION: Type annotations on type arguments for a containing type of return type, with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +class Inv + +fun case_1(): Inv<@Ann(unresolved_reference) String> = TODO() diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/5.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/5.fir.kt new file mode 100644 index 00000000000..6a2e37e10da --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/5.fir.kt @@ -0,0 +1,21 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 5 + * DESCRIPTION: Type annotations on upper bounds with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1, 2 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +// TESTCASE NUMBER: 1 +abstract class Bar + +/* + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + */ +class B where @Ann(unresolved_reference) T : Number diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/6.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/6.fir.kt new file mode 100644 index 00000000000..f2ad275e44b --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/6.fir.kt @@ -0,0 +1,46 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER +// !WITH_NEW_INFERENCE + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 6 + * DESCRIPTION: Type annotations inside type check and cast expression with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1, 2 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +/* + * TESTCASE NUMBER: 1 + * UNEXPECTED BEHAVIOUR + */ +fun case_1(a: Any) { + if (a is @Ann(unresolved_reference) String) return +} + +/* + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + */ +fun case_2(a: Any) { + a as @Ann(unresolved_reference) String // OK, no error in IDE and in the compiler +} + +/* + * TESTCASE NUMBER: 3 + * UNEXPECTED BEHAVIOUR + */ +fun case_3_1(a: Any) {} + +fun case_3_2(a: Any) { + case_3_1(a as @Ann(unresolved_reference) String) // OK, no error in IDE and in the compiler +} + +// TESTCASE NUMBER: 4 +fun case_4(a: Any) { + val x = a as @Ann(unresolved_reference) String // ERROR, has error in IDE and in the compiler +} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/7.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/7.fir.kt new file mode 100644 index 00000000000..59d841be471 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/7.fir.kt @@ -0,0 +1,30 @@ +// !WITH_NEW_INFERENCE + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 7 + * DESCRIPTION: Type annotations on a type in an anonymous object expression, with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1, 2 +@Target(AnnotationTarget.TYPE) +annotation class Ann + +/* + * TESTCASE NUMBER: 1 + * UNEXPECTED BEHAVIOUR + */ +open class TypeToken + +val case_1 = object : TypeToken<@Ann(unresolved_reference) String>() {} + +/* + * TESTCASE NUMBER: 2 + * UNEXPECTED BEHAVIOUR + */ +interface A + +val case_2 = object: @Ann(unresolved_reference) A {} diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/8.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/8.fir.kt new file mode 100644 index 00000000000..da95969fdb9 --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/8.fir.kt @@ -0,0 +1,20 @@ +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 8 + * DESCRIPTION: Type annotations on a receiver type (for an extension property only), with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +// TESTCASE NUMBER: 1, 2 +@Target(AnnotationTarget.TYPE) +annotation class Ann(val x: Int) + +// TESTCASE NUMBER: 1 +val @Ann(unresolved_reference) T.test // OK, error only in IDE but not in the compiler + get() = 10 + +// TESTCASE NUMBER: 2 +val @Ann(unresolved_reference) Int.test + get() = 10 diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/9.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/9.fir.kt new file mode 100644 index 00000000000..5dd10de971a --- /dev/null +++ b/compiler/tests-spec/testData/diagnostics/notLinked/annotations/type-annotations/neg/9.fir.kt @@ -0,0 +1,21 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +/* + * KOTLIN DIAGNOSTICS NOT LINKED SPEC TEST (NEGATIVE) + * + * SECTIONS: annotations, type-annotations + * NUMBER: 9 + * DESCRIPTION: Type annotations on a setter argument type with unresolved reference in parameters. + * ISSUES: KT-28424 + */ + +/* + * TESTCASE NUMBER: 1 + * UNEXPECTED BEHAVIOUR + */ +@Target(AnnotationTarget.TYPE) +annotation class Ann + +var T.test + get() = 11 + set(value: @Ann(unresolved_reference) Int) {}