[FIR] Partial implementation of DEPRECATION(_ERROR) diagnostics

No support for inheritance deprecations
and deprecations in qualifier's parts
This commit is contained in:
Andrey Zinovyev
2021-06-23 15:25:23 +03:00
committed by teamcityserver
parent 9fad55d551
commit de3f31cf78
188 changed files with 984 additions and 1052 deletions
@@ -1,9 +0,0 @@
@Deprecated("text")
annotation class obsolete()
@Deprecated("text")
annotation class obsoleteWithParam(val text: String)
@obsolete class Obsolete
@obsoleteWithParam("text") class Obsolete2
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
@Deprecated("text")
annotation class obsolete()
@@ -1,34 +0,0 @@
// !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")
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: A.kt
@@ -1,11 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Deprecated("alas", level = DeprecationLevel.ERROR)
fun foo() {}
@Deprecated("alas", level = DeprecationLevel.ERROR)
class C
fun test(c: C) {
foo()
C()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
@Deprecated("alas", level = DeprecationLevel.ERROR)
fun foo() {}
@@ -1,21 +0,0 @@
// !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 {}
}
}
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER
class Table
class Tr
@@ -1,11 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
@Deprecated("", level = DeprecationLevel.HIDDEN)
open class Foo
fun test(f: Foo) {
f.toString()
val g: Foo? = Foo()
}
class Bar : Foo()
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_VARIABLE
@Deprecated("", level = DeprecationLevel.HIDDEN)
@@ -1,23 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
object Scope {
fun foo(): Int = 0
object Nested {
@Deprecated("err", level = DeprecationLevel.HIDDEN)
fun foo(): String = ""
fun <T> take(f: () -> T): T = f()
fun test() {
val r1 = take(::foo)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>r1<!>
val r2 = ::foo
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction0<kotlin.String>")!>r2<!>
val r3 = foo()
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>r3<!>
}
}
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
object Scope {
@@ -112,9 +112,9 @@ fun use(
e2: E2, w2: W2, ew2: EW2, hew2: HEW2,
explicitError: ExplicitError
) {
wd.f()
ed.f()
hd.f()
wd.<!DEPRECATION!>f<!>()
ed.<!DEPRECATION_ERROR!>f<!>()
hd.<!INVISIBLE_REFERENCE!>f<!>()
we.f()
wh.f()
@@ -131,10 +131,10 @@ fun use(
nwe2.f()
nwe3.f()
e2.f()
w2.f()
e2.<!DEPRECATION_ERROR!>f<!>()
w2.<!DEPRECATION!>f<!>()
ew2.f()
hew2.f()
explicitError.f()
}
explicitError.<!DEPRECATION_ERROR!>f<!>()
}
@@ -94,20 +94,20 @@ fun use(
sdh: SDH, edh: EDH, ned: NED,
diff: Diff
) {
warningDeprecated.p
warningDeprecated.p = 1
warningDeprecated.<!DEPRECATION!>p<!>
warningDeprecated.p <!DEPRECATION!>=<!> 1
errorDeprecated.p
errorDeprecated.p = 1
errorDeprecated.<!DEPRECATION_ERROR!>p<!>
errorDeprecated.p <!DEPRECATION_ERROR!>=<!> 1
getterDeprecated.p
getterDeprecated.<!DEPRECATION!>p<!>
getterDeprecated.p = 1
setterDeprecated.p
setterDeprecated.p = 1
setterDeprecated.p <!DEPRECATION!>=<!> 1
hiddenDeprecated.p
hiddenDeprecated.p = 1
hiddenDeprecated.<!INVISIBLE_REFERENCE!>p<!>
hiddenDeprecated.<!INVISIBLE_REFERENCE!>p<!> = 1
wd.p
wd.p = 1
@@ -130,6 +130,6 @@ fun use(
ned.p
ned.p = 1
diff.p
diff.p = 1
}
diff.<!DEPRECATION_ERROR!>p<!>
diff.<!INVISIBLE_REFERENCE!>p<!> = 1
}
@@ -1,37 +0,0 @@
// !API_VERSION: 1.4
package kotlin
@Deprecated("")
@DeprecatedSinceKotlin(errorSince = "1.4")
class ClassCur
@Deprecated("")
@DeprecatedSinceKotlin(errorSince = "1.4")
fun funCur() {}
@Deprecated("")
@DeprecatedSinceKotlin(errorSince = "1.4")
val valCur = Unit
@Deprecated("")
@DeprecatedSinceKotlin(errorSince = "1.5")
class ClassNext
@Deprecated("")
@DeprecatedSinceKotlin(errorSince = "1.5")
fun funNext() {}
@Deprecated("")
@DeprecatedSinceKotlin(errorSince = "1.5")
val valNext = Unit
fun usage() {
ClassCur()
funCur()
valCur
ClassNext()
funNext()
valNext
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !API_VERSION: 1.4
package kotlin
@@ -27,9 +27,9 @@ fun funNext() {}
val valNext = Unit
fun usage() {
ClassCur()
<!DEPRECATION_ERROR!>ClassCur<!>()
<!INVISIBLE_REFERENCE!>funCur<!>()
valCur
<!INVISIBLE_REFERENCE!>valCur<!>
ClassNext()
funNext()
@@ -5,5 +5,5 @@ package kotlin
fun foo() {}
fun test() {
foo()
<!DEPRECATION!>foo<!>()
}
@@ -1,37 +0,0 @@
// !API_VERSION: 1.4
package kotlin
@Deprecated("")
@DeprecatedSinceKotlin(warningSince = "1.4")
class ClassCur
@Deprecated("")
@DeprecatedSinceKotlin(warningSince = "1.4")
fun funCur() {}
@Deprecated("")
@DeprecatedSinceKotlin(warningSince = "1.4")
val valCur = Unit
@Deprecated("")
@DeprecatedSinceKotlin(warningSince = "1.5")
class ClassNext
@Deprecated("")
@DeprecatedSinceKotlin(warningSince = "1.5")
fun funNext() {}
@Deprecated("")
@DeprecatedSinceKotlin(warningSince = "1.5")
val valNext = Unit
fun usage() {
ClassCur()
funCur()
valCur
ClassNext()
funNext()
valNext
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !API_VERSION: 1.4
package kotlin
@@ -1,51 +0,0 @@
// !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()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -UNUSED_EXPRESSION
import kotlin.reflect.KProperty
@@ -27,14 +27,14 @@ var v6: String
set(value) {}
fun test() {
v1
v2
v3
<!INVISIBLE_REFERENCE!>v1<!>
<!INVISIBLE_REFERENCE!>v2<!>
<!INVISIBLE_REFERENCE!>v3<!>
v3 = ""
v4
v4 = ""
v5
v5 = ""
v6
v6 = ""
<!INVISIBLE_REFERENCE!>v4<!> = ""
<!INVISIBLE_REFERENCE!>v5<!>
<!INVISIBLE_REFERENCE!>v5<!> = ""
<!INVISIBLE_REFERENCE!>v6<!>
<!INVISIBLE_REFERENCE!>v6<!> = ""
}
@@ -5,4 +5,4 @@ class C {
fun use() {}
}
fun useAlias(c : C2) { c.use() }
fun useAlias(c : <!DEPRECATION!>C2<!>) { c.use() }
@@ -1,16 +0,0 @@
// !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)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !DIAGNOSTICS: -NO_VALUE_FOR_PARAMETER
// FILE: A.java
@@ -1,53 +0,0 @@
// 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.D
C.D
A.bar()
B.bar()
C.bar()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// FILE: A.java
public class A {
@@ -37,30 +37,30 @@ class PropertyHolder {
}
fun PropertyHolder.extFunction() {
test2 = "ext"
test1
test2 <!DEPRECATION!>=<!> "ext"
<!DEPRECATION!>test1<!>
}
fun fn() {
PropertyHolder().test1
PropertyHolder().test2
PropertyHolder().test2 = ""
PropertyHolder().<!DEPRECATION!>test1<!>
PropertyHolder().<!DEPRECATION!>test2<!>
PropertyHolder().test2 <!DEPRECATION!>=<!> ""
PropertyHolder().test3
PropertyHolder().<!DEPRECATION!>test3<!>
PropertyHolder().test3 = ""
PropertyHolder().test4
PropertyHolder().test4 = ""
PropertyHolder().test4 <!DEPRECATION!>=<!> ""
val a = PropertyHolder().x
val b = PropertyHolder().name
PropertyHolder().name = "value"
val a = PropertyHolder().<!DEPRECATION!>x<!>
val b = PropertyHolder().<!DEPRECATION!>name<!>
PropertyHolder().name <!DEPRECATION!>=<!> "value"
val d = PropertyHolder().valDelegate
PropertyHolder().varDelegate = 1
}
fun literals() {
PropertyHolder::test1
PropertyHolder::name
PropertyHolder::<!DEPRECATION!>test1<!>
PropertyHolder::<!DEPRECATION!>name<!>
}
@@ -17,15 +17,15 @@ class PropertyHolder {
fun fn() {
val holder = PropertyHolder()
holder.a1
holder.a2
holder.withGetter
holder.withSetter = "A"
holder.<!DEPRECATION!>a1<!>
holder.<!DEPRECATION!>a2<!>
holder.<!DEPRECATION!>withGetter<!>
holder.withSetter <!DEPRECATION!>=<!> "A"
}
fun literals() {
PropertyHolder::a1
PropertyHolder::a2
PropertyHolder::withGetter
PropertyHolder::<!DEPRECATION!>a1<!>
PropertyHolder::<!DEPRECATION!>a2<!>
PropertyHolder::<!DEPRECATION!>withGetter<!>
PropertyHolder::withSetter
}
@@ -1,42 +0,0 @@
@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().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
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
@Deprecated("Class")
open class Obsolete {
fun use() {}
@@ -6,9 +6,9 @@ open class WithDeprecatedCtor(val x: Int) {
constructor() : this(0)
}
typealias DeprecatedClassAlias = DeprecatedClass
typealias DeprecatedClassAlias = <!DEPRECATION!>DeprecatedClass<!>
typealias WithDeprecatedCtorAlias = WithDeprecatedCtor
typealias ArrayListOfDeprecatedClass = ArrayList<DeprecatedClass>
typealias ArrayListOfDeprecatedClass = ArrayList<<!DEPRECATION!>DeprecatedClass<!>>
class Test1 : DeprecatedClassAlias()
@@ -4,12 +4,12 @@ class Foo
@Deprecated("", level = DeprecationLevel.ERROR)
class Err
typealias Test1 = Foo
typealias Test2 = List<Foo>
typealias Test1 = <!DEPRECATION!>Foo<!>
typealias Test2 = List<<!DEPRECATION!>Foo<!>>
typealias Test3 = List<Test2>
typealias TestErr1 = Err
typealias TestErr2 = List<Err>
typealias TestErr1 = <!DEPRECATION_ERROR!>Err<!>
typealias TestErr2 = List<<!DEPRECATION_ERROR!>Err<!>>
typealias TestErr3 = List<TestErr2>
fun use1(b: Test1) = b
@@ -18,4 +18,4 @@ fun use3(b: Test3) = b
fun useErr1(b: TestErr1) = b
fun useErr2(b: TestErr2) = b
fun useErr3(b: TestErr3) = b
fun useErr3(b: TestErr3) = b
@@ -11,14 +11,14 @@ typealias Obsolete = Base
@Deprecated("Obsolete")
typealias IObsolete = IFoo
fun test1(x: Obsolete) = x
fun test1a(x: List<Obsolete>) = x
fun test1(x: <!DEPRECATION!>Obsolete<!>) = x
fun test1a(x: List<<!DEPRECATION!>Obsolete<!>>) = x
val test2 = Obsolete()
val test3 = Obsolete
class Test4: Obsolete()
class Test4a: IObsolete
class Test4b: IG<Obsolete>
class Test4c: CG<Obsolete>()
class Test4: <!DEPRECATION!>Obsolete<!>()
class Test4a: <!DEPRECATION!>IObsolete<!>
class Test4b: IG<<!DEPRECATION!>Obsolete<!>>
class Test4c: CG<<!DEPRECATION!>Obsolete<!>>()
@@ -3,6 +3,6 @@
@Deprecated("error", level = DeprecationLevel.ERROR)
class Foo @Deprecated("warning", level = DeprecationLevel.WARNING) constructor()
fun test1() = Foo()
fun test1() = <!DEPRECATION_ERROR!>Foo<!>()
fun test2(): Foo = Foo()
fun test2(): <!DEPRECATION_ERROR!>Foo<!> = <!DEPRECATION_ERROR!>Foo<!>()