[FIR] Resolve annotations as calls
This commit is contained in:
committed by
Mikhail Glukhikh
parent
bc1fa8ed7f
commit
721b9b4d8c
+1
-1
@@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
|
||||
val test: Bar = Bar()
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?>
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K, V, V1 : V?>
|
||||
Map<out K, @kotlin.internal.Exact V>.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO()
|
||||
|
||||
fun test() {
|
||||
@@ -14,4 +14,4 @@ fun test() {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int?")!>r2<!>
|
||||
|
||||
map.getOrDefault_Exact("y", "string")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ interface Parent
|
||||
object ChildA : Parent
|
||||
object ChildB : Parent
|
||||
|
||||
fun <@kotlin.internal.OnlyInputTypes T> select(a: T, b: T) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> select(a: T, b: T) {}
|
||||
|
||||
fun test() {
|
||||
select(ChildA, ChildB) // should be error
|
||||
|
||||
Vendored
+4
-4
@@ -7,17 +7,17 @@ class CX : Base()
|
||||
class CY : Base()
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes T> foo(a: T, b: T) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> foo(a: T, b: T) {}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes T : Any> fooA(a: T, b: T) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T : Any> fooA(a: T, b: T) {}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T : Base> fooB(a: T, b: T) {}
|
||||
|
||||
|
||||
fun usage(x: CX, y: CY) {
|
||||
foo(x, y) // expected err, got err
|
||||
fooA(x, y) // expected err, got ok
|
||||
fooB(x, y) // expected err, got ok
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
annotation class Anno
|
||||
|
||||
fun test(a: List<Class<Anno>>) {
|
||||
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
|
||||
}
|
||||
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> S> strictSelect(arg1: S, arg2: S): S = TODO()
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@@ -10,4 +9,4 @@ fun test(a: List<Class<Anno>>) {
|
||||
strictSelect(a, emptyList<Anno>().map { it.annotationClass.java })
|
||||
}
|
||||
|
||||
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
|
||||
fun <@kotlin.internal.OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = TODO()
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@kotlin.jvm.JvmName("containsAny")
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
|
||||
public fun <T> Iterable<T>.contains1(element: T): Int = null!!
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@@ -13,4 +13,4 @@ public fun <T> Iterable<T>.contains1(element: @kotlin.internal.NoInfer T): Boole
|
||||
fun test() {
|
||||
val a: Boolean = listOf(1).contains1("")
|
||||
val b: Boolean = listOf(1).contains1(1)
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
// FILE: TestBase.java
|
||||
|
||||
public class TestBase<T> { }
|
||||
|
||||
// FILE: Test.java
|
||||
|
||||
public class Test<K> extends TestBase<K> { }
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> TestBase<out K>.foo(key: K) = null
|
||||
fun foo(result: Test<*>) {
|
||||
result.foo("sd") // Type inference failed (NI), OK in OI
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +NewInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@@ -16,4 +15,4 @@ public class Test<K> extends TestBase<K> { }
|
||||
fun <@kotlin.internal.OnlyInputTypes K> TestBase<out K>.foo(key: K) = null
|
||||
fun foo(result: Test<*>) {
|
||||
result.foo("sd") // Type inference failed (NI), OK in OI
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
interface IFace<K, out V>
|
||||
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K, V> IFace<out K, V>.get(key: K): V? = TODO()
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> I> id(arg: I): I = arg
|
||||
|
||||
interface InvBase<B>
|
||||
class DerivedInv : InvBase<DerivedInv>
|
||||
class InvRecursive<E : InvBase<E>>
|
||||
|
||||
fun test1(argument: InvRecursive<*>, receiver: IFace<InvRecursive<DerivedInv>, Any>) {
|
||||
receiver.get(argument)
|
||||
}
|
||||
|
||||
fun test2(arg: InvRecursive<out DerivedInv>) {
|
||||
id(arg)
|
||||
}
|
||||
|
||||
fun test3(arg: InvRecursive<in DerivedInv>) {
|
||||
id(arg)
|
||||
}
|
||||
-1
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@file:Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
|
||||
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.contains1(element: T): Boolean = null!!
|
||||
|
||||
class In<in T>
|
||||
|
||||
|
||||
+5
-5
@@ -4,19 +4,19 @@
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@kotlin.jvm.JvmName("containsAny")
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
|
||||
public fun <T> Iterable<T>.contains1(element: T): Int = null!!
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
|
||||
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.contains1(element: T): Boolean = null!!
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
@JvmName("getAny")
|
||||
@kotlin.internal.LowPriorityInOverloadResolution
|
||||
<!HIDDEN!>@kotlin.internal.LowPriorityInOverloadResolution<!>
|
||||
public fun <K, V> Map<K, V>.get1(key: Any?): Int = null!!
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
public fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get1(key: K): V? = null!!
|
||||
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K, V> Map<out K, V>.get1(key: K): V? = null!!
|
||||
|
||||
fun test(map: Map<Int, String>) {
|
||||
val a: Int = listOf(1).contains1("")
|
||||
@@ -24,4 +24,4 @@ fun test(map: Map<Int, String>) {
|
||||
|
||||
val c: String? = map.get1("")
|
||||
val d: String? = map.get1(1)
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -5,13 +5,13 @@
|
||||
class Inv<T>
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes K> Inv<out K>.onlyOut(e: K) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> Inv<out K>.onlyOut(e: K) {}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes K : Number> Inv<out K>.onlyOutUB(e: K) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K : Number> Inv<out K>.onlyOutUB(e: K) {}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes K> Inv<in K>.onlyIn(e: K) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> Inv<in K>.onlyIn(e: K) {}
|
||||
|
||||
fun test(
|
||||
invStar: Inv<*>,
|
||||
@@ -71,4 +71,4 @@ class Test5 {
|
||||
}
|
||||
field = value
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
//!DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
//FILE:Foo.java
|
||||
|
||||
public class Foo {
|
||||
public static String foo() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//FILE:Bar.kt
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> assertEquals1(t1: T, t2: T) {}
|
||||
|
||||
fun test() {
|
||||
assertEquals1(null, Foo.foo())
|
||||
assertEquals1("", Foo.foo())
|
||||
}
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
// FIR_IDENTICAL
|
||||
//!DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
//FILE:Foo.java
|
||||
@@ -17,4 +16,4 @@ fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {}
|
||||
fun test() {
|
||||
assertEquals1(null, Foo.foo())
|
||||
assertEquals1("", Foo.foo())
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -4,10 +4,10 @@
|
||||
// Issue: KT-26698
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.contains1(element: T): Boolean = null!!
|
||||
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.contains1(element: T): Boolean = null!!
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> Iterable<T>.foo(element: T): T = null!!
|
||||
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> Iterable<T>.foo(element: T): T = null!!
|
||||
|
||||
class Inv<T>
|
||||
class Inv2<T, R>
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@ class InB<in C : Bound>(v: C)
|
||||
class Out<out O>(val v: O)
|
||||
class OutB<out O : Bound>(val v: O)
|
||||
|
||||
fun <@OnlyInputTypes M> strictId(arg: M): M = arg
|
||||
fun <@OnlyInputTypes S> strictSelect(arg1: S, arg2: S): S = arg1
|
||||
fun <<!HIDDEN!>@OnlyInputTypes<!> M> strictId(arg: M): M = arg
|
||||
fun <<!HIDDEN!>@OnlyInputTypes<!> S> strictSelect(arg1: S, arg2: S): S = arg1
|
||||
|
||||
fun testOK(first: First, bound: Bound, second: Second) {
|
||||
strictId(Inv(15))
|
||||
|
||||
+1
-1
@@ -10,4 +10,4 @@ fun <T> foo(i: Inv<in T>, o: Out<T>) {
|
||||
bar(i, o)
|
||||
}
|
||||
|
||||
fun <@kotlin.internal.OnlyInputTypes K> bar(r: Inv<out K>, o: Out<K>): K = TODO()
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> K> bar(r: Inv<out K>, o: Out<K>): K = TODO()
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes S> select(a1: S, a2: S): S = TODO()
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> S> select(a1: S, a2: S): S = TODO()
|
||||
|
||||
interface Common
|
||||
class First : Common
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
fun <@kotlin.internal.OnlyInputTypes T> assertEquals1(t1: T, t2: T) {}
|
||||
fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> assertEquals1(t1: T, t2: T) {}
|
||||
|
||||
open class A
|
||||
class B: A()
|
||||
@@ -19,8 +19,8 @@ fun test1(a: A, b: B, c: C) {
|
||||
}
|
||||
|
||||
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
|
||||
public fun <@kotlin.internal.OnlyInputTypes T> expect1(expected: T, block: () -> T) {}
|
||||
public fun <<!HIDDEN!>@kotlin.internal.OnlyInputTypes<!> T> expect1(expected: T, block: () -> T) {}
|
||||
|
||||
fun test() {
|
||||
expect1(2) { byteArrayOf(1, 2, 3).indexOf(3) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user