Revert "[NI] Support @OnlyInputTypes annotation. #KT-29307 fixed"

This reverts commit 90628112
With that annotation there is complex bug that breaks build of Kotlin compiler
This commit is contained in:
Dmitriy Novozhilov
2019-03-18 18:51:52 +03:00
parent 25b3f62767
commit d01b6ef900
20 changed files with 31 additions and 210 deletions
@@ -6,6 +6,6 @@ public @interface A {
}
// FILE: b.kt
@A(*<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(<!NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "b")<!>)
@A(*<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH("Array<out String>", "IGNORE")!>arrayOf(1, "b")<!>)
fun test() {
}
@@ -2,6 +2,6 @@
annotation class B(vararg val args: String)
@B(*<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>arrayOf(<!NI;CONSTANT_EXPECTED_TYPE_MISMATCH, NI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>, "b")<!>)
@B(*<!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH("Array<out String>", "IGNORE")!>arrayOf(1, "b")<!>)
fun test() {
}
@@ -4,7 +4,7 @@ interface A
class B : A
fun foo1(list: List<A>, arg: B?): Boolean {
// Type mismatch
return arg <!TYPE_INFERENCE_ONLY_INPUT_TYPES!>in<!> list // resolved to extension
return arg <!OI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>in<!> list // resolved to extension
}
fun foo2(list: List<A>, arg: B?): Boolean {
// FAKE: no cast needed
@@ -4,7 +4,7 @@ import java.util.*
fun foo() {
val al = ArrayList<String>()
al.size
al.<!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>contains<!>(<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
al.contains(<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
al.contains("")
al.remove("")
@@ -12,7 +12,7 @@ fun foo() {
val hs = HashSet<String>()
hs.size
hs.<!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>contains<!>(<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
hs.contains(<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
hs.contains("")
hs.remove("")
@@ -20,10 +20,10 @@ fun foo() {
val hm = HashMap<String, Int>()
hm.size
hm.<!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>containsKey<!>(<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
hm.containsKey(<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
hm.containsKey("")
<!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>hm[<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>]<!>
hm[<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>]
hm[""]
hm.remove("")
@@ -1,22 +0,0 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
// !WITH_NEW_INFERENCE
open class Base()
class CX : Base()
class CY : Base()
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@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) {}
@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE")
fun <@kotlin.internal.OnlyInputTypes T : Base> fooB(a: T, b: T) {}
fun usage(x: CX, y: CY) {
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>foo<!>(x, y) // expected err, got err
<!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>fooA<!>(x, y) // expected err, got ok
<!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>fooB<!>(x, y) // expected err, got ok
}
@@ -1,27 +0,0 @@
package
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ @kotlin.internal.OnlyInputTypes T> foo(/*0*/ a: T, /*1*/ b: T): kotlin.Unit
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ @kotlin.internal.OnlyInputTypes T : kotlin.Any> fooA(/*0*/ a: T, /*1*/ b: T): kotlin.Unit
@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun </*0*/ @kotlin.internal.OnlyInputTypes T : Base> fooB(/*0*/ a: T, /*1*/ b: T): kotlin.Unit
public fun usage(/*0*/ x: CX, /*1*/ y: CY): kotlin.Unit
public open class Base {
public constructor Base()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class CX : Base {
public constructor CX()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class CY : Base {
public constructor CY()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -1,31 +0,0 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE
// !WITH_NEW_INFERENCE
// ISSUE: KT-29307
fun test_1(map: Map<String, String>) {
val x = <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>map[<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>]<!> // OK
}
open class A
class B : A()
fun test_2(map: Map<A, String>) {
val x = <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>map[<!OI;CONSTANT_EXPECTED_TYPE_MISMATCH!>42<!>]<!>
}
fun test_3(m: Map<*, String>) {
val x = m[42] // should be ok
}
fun test_4(m: Map<out Number, String>) {
val x = m.get(42) // should be ok
}
fun test_5(map: Map<B, Int>, a: A) {
map.get(a)
}
fun test_6(map: Map<A, Int>, b: B) {
map.get(b)
}
@@ -1,22 +0,0 @@
package
public fun test_1(/*0*/ map: kotlin.collections.Map<kotlin.String, kotlin.String>): kotlin.Unit
public fun test_2(/*0*/ map: kotlin.collections.Map<A, kotlin.String>): kotlin.Unit
public fun test_3(/*0*/ m: kotlin.collections.Map<*, kotlin.String>): kotlin.Unit
public fun test_4(/*0*/ m: kotlin.collections.Map<out kotlin.Number, kotlin.String>): kotlin.Unit
public fun test_5(/*0*/ map: kotlin.collections.Map<B, kotlin.Int>, /*1*/ a: A): kotlin.Unit
public fun test_6(/*0*/ map: kotlin.collections.Map<A, kotlin.Int>, /*1*/ b: B): kotlin.Unit
public open class 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 hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class B : A {
public constructor B()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -18,9 +18,9 @@ public fun <K, V> Map<K, V>.get1(key: Any?): Int = null!!
public fun <@kotlin.internal.OnlyInputTypes K, V> Map<out K, V>.get1(key: K): V? = null!!
fun test(map: Map<Int, String>) {
val a: Int = <!NI;TYPE_MISMATCH!>listOf(1).<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!><!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>contains1<!>("")<!><!>
val a: Int = <!NI;TYPE_MISMATCH!>listOf(1).<!NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>contains1("")<!><!>
val b: Boolean = listOf(1).contains1(1)
val c: String? = map.<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>get1<!>("")
val c: String? = map.<!OI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>get1<!>("")
val d: String? = map.get1(1)
}
@@ -11,7 +11,7 @@ class D
fun test1(a: A, b: B, c: C) {
assertEquals1(a, b)
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>assertEquals1<!>(b, c)
<!OI;TYPE_INFERENCE_ONLY_INPUT_TYPES!>assertEquals1<!>(b, c)
assertEquals1(3, 3)
assertEquals1(1 or 2, 2 or 1)
@@ -28,8 +28,8 @@ fun main() {
"" in (hm as Map<String, Int>)
"" !in (hm as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (hm as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (hm as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (hm as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (hm as Map<String, Int>)
val a = A()
"" <!CONCURRENT_HASH_MAP_CONTAINS_OPERATOR!>in<!> a
@@ -44,8 +44,8 @@ fun main() {
"" in (a as Map<String, Int>)
"" !in (a as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (a as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (a as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (a as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (a as Map<String, Int>)
val b = B()
"" <!CONCURRENT_HASH_MAP_CONTAINS_OPERATOR!>in<!> b
@@ -58,8 +58,8 @@ fun main() {
"" in (b as Map<String, Int>)
"" !in (b as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (b as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (b as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (b as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (b as Map<String, Int>)
// Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird
val c = C()
@@ -73,7 +73,7 @@ fun main() {
"" in (c as Map<String, Int>)
"" !in (c as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (c as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (c as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (c as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (c as Map<String, Int>)
}
@@ -29,8 +29,8 @@ fun main() {
"" in (hm as Map<String, Int>)
"" !in (hm as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (hm as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (hm as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (hm as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (hm as Map<String, Int>)
val a = A()
"" <!CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR!>in<!> a
@@ -45,8 +45,8 @@ fun main() {
"" in (a as Map<String, Int>)
"" !in (a as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (a as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (a as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (a as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (a as Map<String, Int>)
val b = B()
"" <!CONCURRENT_HASH_MAP_CONTAINS_OPERATOR_ERROR!>in<!> b
@@ -59,8 +59,8 @@ fun main() {
"" in (b as Map<String, Int>)
"" !in (b as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (b as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (b as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (b as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (b as Map<String, Int>)
// Actually, we could've allow calls here because the owner explicitly declared as operator, but semantics is still weird
val c = C()
@@ -74,7 +74,7 @@ fun main() {
"" in (c as Map<String, Int>)
"" !in (c as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (c as Map<String, Int>)
1 <!NI;TYPE_INFERENCE_ONLY_INPUT_TYPES, OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (c as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>in<!> (c as Map<String, Int>)
1 <!OI;TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS!>!in<!> (c as Map<String, Int>)
}