[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,9 @@
@Deprecated("text")
annotation class obsolete()
@Deprecated("text")
annotation class obsoleteWithParam(val text: String)
@obsolete class Obsolete
@obsoleteWithParam("text") class Obsolete2
@@ -0,0 +1,8 @@
class A {
@Deprecated("deprecated") companion object
class B
}
val x1 = A.B()
@@ -0,0 +1,32 @@
class Another {
@Deprecated("Object")
companion object {
fun use() {}
const val USE = 42
}
}
fun first() {
Another.use()
Another.Companion.USE
Another.USE
}
fun useCompanion() {
val d = Another
val x = Another.Companion
Another.Companion.use()
Another.use()
}
@Deprecated("Some")
class Some {
companion object {
fun use() {}
}
}
fun some() {
Some.use()
Some.Companion.use()
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
class Data {
@Deprecated("text")
operator fun component1(): String = throw Exception()
operator fun component2(): String = throw Exception()
}
fun use() {
val (x, y) = Data()
}
@@ -0,0 +1,34 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: A.kt
class A(s: String) {
@Deprecated("")
constructor(i: Int) : this(i.toString()) {
}
}
// FILE: B.java
public class B extends A {
@Deprecated
public B(int i) {
}
public B(String s) {
}
}
// FILE: C.kt
class C @Deprecated("") constructor(s: String) {
}
// FILE: use.kt
fun use(a: A, b: B, c: C) {
A(3)
A("")
B(3)
B("")
C("s")
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Deprecated("alas", level = DeprecationLevel.ERROR)
fun foo() {}
@Deprecated("alas", level = DeprecationLevel.ERROR)
class C
fun test(c: C) {
foo()
C()
}
@@ -0,0 +1,21 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Table
class Tr
fun table(body: Table.() -> Unit) {}
fun Table.tr(body: Tr.() -> Unit) {}
@Deprecated("Don't call me", level = DeprecationLevel.ERROR)
fun Tr.tr(body: Tr.() -> Unit) {}
fun builderTest() {
table {
tr {
tr {}
table {
tr {
tr {}
}
}
}
}
}
@@ -0,0 +1,11 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
@Deprecated("", level = DeprecationLevel.HIDDEN)
open class Foo
fun test(f: Foo) {
f.toString()
val g: Foo? = Foo()
}
class Bar : Foo()
@@ -0,0 +1,140 @@
package foo
interface WarningDeprecated {
@Deprecated("", level = DeprecationLevel.WARNING)
fun f() {
}
}
interface ErrorDeprecated {
@Deprecated("", level = DeprecationLevel.ERROR)
fun f() {
}
}
interface HiddenDeprecated {
@Deprecated("", level = DeprecationLevel.HIDDEN)
fun f() {
}
}
interface NotDeprecated {
fun f() {
}
}
open class WE : WarningDeprecated, ErrorDeprecated {
override fun f() {
}
}
open class WH : WarningDeprecated, HiddenDeprecated {
override fun f() {
}
}
open class EH : ErrorDeprecated, HiddenDeprecated {
override fun f() {
}
}
open class NW : WarningDeprecated, NotDeprecated {
override fun f() {
}
}
open class NE : ErrorDeprecated, NotDeprecated {
override fun f() {
}
}
open class NH : HiddenDeprecated, NotDeprecated {
override fun f() {
}
}
open class WEH: WarningDeprecated, ErrorDeprecated, HiddenDeprecated {
override fun f() {
}
}
open class NWEH: NotDeprecated, WarningDeprecated, ErrorDeprecated, HiddenDeprecated {
override fun f() {
}
}
class WE2: WE()
class NWE2: WE(), NotDeprecated
class NWE3: WE(), NotDeprecated {
override fun f() {
}
}
interface E2: ErrorDeprecated
interface W2: WarningDeprecated
interface EW2: E2, W2 {
override fun f() {
}
}
interface HEW2: EW2, HiddenDeprecated {
override fun f() {
}
}
interface ExplicitError: HEW2 {
@Deprecated("", level = DeprecationLevel.ERROR)
override fun f() {
super.f()
}
}
fun use(
wd: WarningDeprecated, ed: ErrorDeprecated, hd: HiddenDeprecated,
we: WE, wh: WH, eh: EH, nw: NW, ne: NE, nh: NH,
weh: WEH, nweh: NWEH,
we2: WE2, nwe2: NWE2, nwe3: NWE3,
e2: E2, w2: W2, ew2: EW2, hew2: HEW2,
explicitError: ExplicitError
) {
wd.f()
ed.f()
hd.f()
we.f()
wh.f()
eh.f()
nw.f()
ne.f()
nh.f()
weh.f()
nweh.f()
we2.f()
nwe2.f()
nwe3.f()
e2.f()
w2.f()
ew2.f()
hew2.f()
explicitError.f()
}
@@ -0,0 +1,135 @@
package foo
interface HiddenDeprecated {
@Deprecated("", level = DeprecationLevel.HIDDEN)
var p: Int
}
interface NoDeprecation {
var p: Int
}
open class WarningDeprecated {
@Deprecated("", level = DeprecationLevel.WARNING)
open var p: Int = 3
}
open class ErrorDeprecated {
@Deprecated("", level = DeprecationLevel.ERROR)
open var p: Int = 3
}
open class GetterDeprecated {
open var p: Int = 3
@Deprecated("") get
}
open class SetterDeprecated {
open var p: Int = 3
@Deprecated("") set
}
class WD: WarningDeprecated() {
override var p: Int
get() = 3
set(value) {}
}
class ED: ErrorDeprecated() {
override var p: Int
get() = 3
set(value) {
}
}
class GD: GetterDeprecated() {
override var p: Int
get() = 3
set(value) {
}
}
class SD: SetterDeprecated() {
override var p: Int
get() = 3
set(value) {
}
}
class SDH: SetterDeprecated(), HiddenDeprecated {
override var p: Int
get() = 3
set(value) {
}
}
class EDH: ErrorDeprecated(), HiddenDeprecated {
override var p: Int
get() = 3
set(value) {
}
}
class NED: ErrorDeprecated(), NoDeprecation {
override var p: Int
get() = 3
set(value) {
}
}
class Diff {
@Deprecated("", level = DeprecationLevel.WARNING)
var p: Int
@Deprecated("", level = DeprecationLevel.ERROR) get() = 3
@Deprecated("", level = DeprecationLevel.HIDDEN) set(value) {
}
}
fun use(
warningDeprecated: WarningDeprecated, errorDeprecated: ErrorDeprecated, setterDeprecated: SetterDeprecated,
getterDeprecated: GetterDeprecated, hiddenDeprecated: HiddenDeprecated,
wd: WD, ed: ED, gd: GD, sd: SD,
sdh: SDH, edh: EDH, ned: NED,
diff: Diff
) {
warningDeprecated.p
warningDeprecated.p = 1
errorDeprecated.p
errorDeprecated.p = 1
getterDeprecated.p
getterDeprecated.p = 1
setterDeprecated.p
setterDeprecated.p = 1
hiddenDeprecated.p
hiddenDeprecated.p = 1
wd.p
wd.p = 1
ed.p
ed.p = 1
gd.p
gd.p = 1
sd.p
sd.p = 1
sdh.p
sdh.p = 1
edh.p
edh.p = 1
ned.p
ned.p = 1
diff.p
diff.p = 1
}
@@ -0,0 +1,51 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KProperty
class UsefulClass(val param: Int = 2) {
operator fun getValue(instance: Any, property: KProperty<*>) : Int = 1
operator fun setValue(instance: Any, property: KProperty<*>, value: Int) {}
@Deprecated("message")
fun member() {}
}
@Deprecated("message")
fun Obsolete(param: Int = 1): UsefulClass = UsefulClass(param)
class Invocable {
@Deprecated("message")
operator fun invoke() {}
}
object InvocableHolder {
val invocable = Invocable()
}
fun invoker() {
val invocable = Invocable()
invocable()
InvocableHolder.invocable()
}
fun block() {
Obsolete()
Obsolete(2)
}
fun expression() = Obsolete()
fun reflection() = ::Obsolete
fun reflection2() = UsefulClass::member
class Initializer {
val x = Obsolete()
}
@Deprecated("does nothing good")
fun Any.doNothing() = this.toString() // "this" should not be marked as deprecated despite it referes to deprecated function
class Delegation {
val x by Obsolete()
var y by Obsolete()
}
@@ -0,0 +1,8 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION, -UNUSED_PARAMETER
open class C<T>() {
@Deprecated("")
constructor(p: Int) : this(){}
}
class D : C<String>(1)
@@ -0,0 +1,40 @@
val v1: String
@Deprecated("", level = DeprecationLevel.HIDDEN)
get() = ""
@Deprecated("", level = DeprecationLevel.HIDDEN)
val v2 = ""
var v3: String
@Deprecated("", level = DeprecationLevel.HIDDEN)
get() = ""
set(value) {}
var v4: String
get() = ""
@Deprecated("", level = DeprecationLevel.HIDDEN)
set(value) {}
var v5: String
@Deprecated("", level = DeprecationLevel.HIDDEN)
get() = ""
@Deprecated("", level = DeprecationLevel.HIDDEN)
set(value) {}
@Deprecated("", level = DeprecationLevel.HIDDEN)
var v6: String
get() = ""
set(value) {}
fun test() {
v1
v2
v3
v3 = ""
v4
v4 = ""
v5
v5 = ""
v6
v6 = ""
}
@@ -0,0 +1,13 @@
// SKIP_TXT
// FILE: test/J.java
package test;
@Deprecated
public interface J {
public String foo(int x);
}
// FILE: K.kt
import test.J
@@ -0,0 +1,8 @@
import C as C2
@Deprecated("obsolete")
class C {
fun use() {}
}
fun useAlias(c : C2) { c.use() }
@@ -0,0 +1,24 @@
class Iter {
@Deprecated("text")
operator fun iterator() : IterIterator = throw Exception()
class IterIterator {
operator fun hasNext(): Boolean = throw UnsupportedOperationException()
operator fun next(): String = throw UnsupportedOperationException()
}
}
class Iter2 {
operator fun iterator() : Iter2Iterator = throw Exception()
class Iter2Iterator {
@Deprecated("text")
operator fun hasNext(): Boolean = throw UnsupportedOperationException()
@Deprecated("text")
operator fun next(): String = throw UnsupportedOperationException()
}
}
fun use() {
for (x in Iter()) {}
for (x in Iter2()) {}
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -NO_VALUE_FOR_PARAMETER
// FILE: A.java
@Deprecated
public class A {
@Deprecated
public String getFoo(String text) {
return text;
}
}
// FILE: B.kt
class B(private @property:Deprecated val foo: String) : A() {
override fun getFoo(text: String): String = super.getFoo(text + foo)
}
@@ -0,0 +1,53 @@
// FILE: A.java
public class A {
@Deprecated
public static final String D = "d";
@Deprecated
public void f() {
return text;
}
@Deprecated
public static void bar() {
}
}
// FILE: B.java
public class B extends A {
public static final String D = "d";
@Override
public void f() {
return text;
}
public static void bar() {
}
}
// FILE: C.java
public class C extends A {
}
// FILE: use.kt
fun use(a: A, b: B, c: C) {
a.f()
b.f()
c.f()
A.D
B.<!AMBIGUITY!>D<!>
C.D
A.bar()
B.bar()
C.bar()
}
@@ -0,0 +1,20 @@
// !DIAGNOSTICS: -NO_VALUE_FOR_PARAMETER
// FILE: A.java
/**
* @deprecated
*/
public class A {
/**
* @deprecated
*/
public String getFoo(String text) {
return text;
}
}
// FILE: B.kt
class B(private val foo: String) : A() {
override fun getFoo(text: String): String = super.getFoo(text + foo)
}
@@ -0,0 +1,18 @@
class TopLevel {
@Deprecated("Nested")
class Nested {
companion object {
fun use() {}
class CompanionNested2
}
class Nested2
}
}
fun useNested() {
val d = TopLevel.Nested.use()
TopLevel.Nested.Nested2()
TopLevel.Nested.CompanionNested2()
}
@@ -0,0 +1,9 @@
@Deprecated("Object")
object Obsolete {
fun use() {}
}
fun useObject() {
Obsolete.use()
val x = Obsolete
}
@@ -0,0 +1,66 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KProperty
class Delegate() {
@Deprecated("text")
operator fun getValue(instance: Any, property: KProperty<*>) : Int = 1
@Deprecated("text")
operator fun setValue(instance: Any, property: KProperty<*>, value: Int) {}
}
class PropertyHolder {
@Deprecated("text")
val x = 1
@Deprecated("text")
var name = "String"
val valDelegate by Delegate()
var varDelegate by Delegate()
public val test1: String = ""
@Deprecated("val-getter") get
public var test2: String = ""
@Deprecated("var-getter") get
@Deprecated("var-setter") set
public var test3: String = ""
@Deprecated("var-getter") get
set
public var test4: String = ""
get
@Deprecated("var-setter") set
}
fun PropertyHolder.extFunction() {
test2 = "ext"
test1
}
fun fn() {
PropertyHolder().test1
PropertyHolder().test2
PropertyHolder().test2 = ""
PropertyHolder().test3
PropertyHolder().test3 = ""
PropertyHolder().test4
PropertyHolder().test4 = ""
val a = PropertyHolder().x
val b = PropertyHolder().name
PropertyHolder().name = "value"
val d = PropertyHolder().valDelegate
PropertyHolder().varDelegate = 1
}
fun literals() {
PropertyHolder::test1
PropertyHolder::name
}
@@ -0,0 +1,31 @@
// !DIAGNOSTICS: -UNUSED_EXPRESSION
class PropertyHolder {
@Deprecated("")
val a1 = 1
@property:Deprecated("")
var a2 = ""
@get:Deprecated("")
public val withGetter: String = ""
@set:Deprecated("")
public var withSetter: String = ""
}
fun fn() {
val holder = PropertyHolder()
holder.a1
holder.a2
holder.withGetter
holder.withSetter = "A"
}
fun literals() {
PropertyHolder::a1
PropertyHolder::a2
PropertyHolder::withGetter
PropertyHolder::withSetter
}
@@ -0,0 +1,6 @@
@Deprecated("No")
val f: () -> Unit = {}
fun test() {
f()
}
@@ -0,0 +1,7 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
@Deprecated("Use A instead") open class MyClass {
fun foo() {
val test = this
}
}
@@ -0,0 +1,42 @@
@Deprecated("Class")
open class Obsolete {
fun use() {}
}
@Deprecated("Class")
open class Obsolete2 @Deprecated("Constructor") constructor() {
fun use() {}
}
interface Generic<T>
open class Derived() : Obsolete()
class Derived2() : Derived()
class TypeParam : Generic<Obsolete>
object Object : Obsolete()
class Properties {
val x : Obsolete = Obsolete()
var y : Obsolete = Obsolete()
var n : Obsolete
get() = Obsolete()
set(value) {}
}
fun param(param: Obsolete) { param.use() }
fun funcParamReceiver(param: Obsolete.()->Unit) { Obsolete().<!UNRESOLVED_REFERENCE!>param<!>() }
fun funcParamParam(param: (Obsolete)->Unit) { param(Obsolete()) }
fun funcParamRetVal(param: ()->Obsolete) { param() }
fun <T: Obsolete> constraint() {}
fun Obsolete.receiver() {}
fun retVal(): Obsolete = Obsolete()
fun nullableRetVal(): Obsolete? = null
@@ -0,0 +1,12 @@
class Relevant {
companion object {
val value = ""
}
}
@Deprecated("Use Relevant")
typealias Obsolete = Relevant
fun test1() = Obsolete
fun test2() = Obsolete.<!UNRESOLVED_REFERENCE!>value<!>
fun test3() = Obsolete.toString()
@@ -0,0 +1,17 @@
@Deprecated("Deprecated class")
open class DeprecatedClass
open class WithDeprecatedCtor(val x: Int) {
@Deprecated("Deprecated constructor")
constructor() : this(0)
}
typealias DeprecatedClassAlias = DeprecatedClass
typealias WithDeprecatedCtorAlias = WithDeprecatedCtor
typealias ArrayListOfDeprecatedClass = ArrayList<DeprecatedClass>
class Test1 : DeprecatedClassAlias()
class Test2 : WithDeprecatedCtorAlias()
val test3 = ArrayListOfDeprecatedClass()
@@ -0,0 +1,21 @@
@Deprecated("")
class Foo
@Deprecated("", level = DeprecationLevel.ERROR)
class Err
typealias Test1 = Foo
typealias Test2 = List<Foo>
typealias Test3 = List<Test2>
typealias TestErr1 = Err
typealias TestErr2 = List<Err>
typealias TestErr3 = List<TestErr2>
fun use1(b: Test1) = b
fun use2(b: Test2) = b
fun use3(b: Test3) = b
fun useErr1(b: TestErr1) = b
fun useErr2(b: TestErr2) = b
fun useErr3(b: TestErr3) = b
@@ -0,0 +1,24 @@
open class Base {
companion object
}
interface IFoo
open class CG<T>
interface IG<T>
@Deprecated("Obsolete")
typealias Obsolete = Base
@Deprecated("Obsolete")
typealias IObsolete = IFoo
fun test1(x: Obsolete) = x
fun test1a(x: List<Obsolete>) = x
val test2 = Obsolete()
val test3 = Obsolete
class Test4: Obsolete()
class Test4a: IObsolete
class Test4b: IG<Obsolete>
class Test4c: CG<Obsolete>()
@@ -0,0 +1,10 @@
// FILE: A.kt
package test
@Deprecated("A")
interface A
// FILE: B.kt
import test.A
@@ -0,0 +1,8 @@
// KT-15245 Report deprecation on associated declarations if level is greater than the deprecation on the declaration itself
@Deprecated("error", level = DeprecationLevel.ERROR)
class Foo @Deprecated("warning", level = DeprecationLevel.WARNING) constructor()
fun test1() = Foo()
fun test2(): Foo = Foo()