[TEST] Change semantics of CHECK_TYPE directive and update testdata
Previously helpers from checkType.kt was in special package, and
if directive was enabled then test runner (`AbstractDiagnosticTest`)
injected additional imports to test files and removed them after test
was completed.
It's very hard to support such behavior in new test infrastructure so
there was a decision about changing `CHECK_TYPE`:
1. All helpers from `checkType.kt` now stays in default package
2. `CHECK_TYPE` only adds `checkType.kt` to set of analyzed files
and don't modify their content
For test which are written in default package (most of tests actually)
there are no changes. On the other hand if there is a test where dev
want to use checkType functions in testfile with some package then he
should explicitly import functions which he needed (`checkSubtype`,
`checkType`, `_`)
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
|
||||
package foo
|
||||
|
||||
import checkType
|
||||
import checkSubtype
|
||||
|
||||
fun Any.foo() : () -> Unit {
|
||||
return {}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
|
||||
package foo
|
||||
|
||||
import checkType
|
||||
import checkSubtype
|
||||
|
||||
fun Any.foo() : () -> Unit {
|
||||
return {}
|
||||
}
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package test
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
fun foo(): String = "companion"
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package test
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
fun foo(): String = "companion"
|
||||
|
||||
Vendored
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package first
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
@@ -14,7 +16,7 @@ class A {
|
||||
package other
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
import checkSubtype
|
||||
import first.A
|
||||
|
||||
fun main() {
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package first
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
@@ -14,7 +16,7 @@ class A {
|
||||
package other
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
import checkSubtype
|
||||
import first.A
|
||||
|
||||
fun main() {
|
||||
|
||||
Vendored
+3
@@ -4,6 +4,8 @@
|
||||
|
||||
package first
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A
|
||||
|
||||
fun A.foo() {}
|
||||
@@ -18,6 +20,7 @@ import kotlin.reflect.KFunction1
|
||||
|
||||
import first.A
|
||||
import first.foo
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val x = first.A::foo
|
||||
|
||||
Vendored
+3
@@ -4,6 +4,8 @@
|
||||
|
||||
package first
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A
|
||||
|
||||
fun A.foo() {}
|
||||
@@ -18,6 +20,7 @@ import kotlin.reflect.KFunction1
|
||||
|
||||
import first.A
|
||||
import first.foo
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val x = first.A::foo
|
||||
|
||||
Vendored
+3
@@ -3,6 +3,8 @@
|
||||
|
||||
package first
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun foo() {}
|
||||
fun bar(x: Int) {}
|
||||
fun baz() = "OK"
|
||||
@@ -16,6 +18,7 @@ import kotlin.reflect.*
|
||||
import first.foo
|
||||
import first.bar
|
||||
import first.baz
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
|
||||
+3
@@ -3,6 +3,8 @@
|
||||
|
||||
package first
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun foo() {}
|
||||
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
fun baz() = "OK"
|
||||
@@ -16,6 +18,7 @@ import kotlin.reflect.*
|
||||
import first.foo
|
||||
import first.bar
|
||||
import first.baz
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val x = ::foo
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
//KT-2631 Check multiple assignment
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class MyClass {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = "a"
|
||||
@@ -24,4 +26,4 @@ fun test(mc1: MyClass, mc2: MyClass2) {
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(a)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(b)
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(c)
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
//KT-2631 Check multiple assignment
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class MyClass {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = "a"
|
||||
@@ -24,4 +26,4 @@ fun test(mc1: MyClass, mc2: MyClass2) {
|
||||
checkSubtype<Boolean>(<!TYPE_MISMATCH!>a<!>)
|
||||
checkSubtype<Boolean>(<!TYPE_MISMATCH!>b<!>)
|
||||
checkSubtype<Boolean>(<!TYPE_MISMATCH!>c<!>)
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package m
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun test(i: Int?) {
|
||||
if (i != null) {
|
||||
foo(l1@ i)
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package m
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun test(i: Int?) {
|
||||
if (i != null) {
|
||||
foo(<!REDUNDANT_LABEL_WARNING!>l1@<!> <!DEBUG_INFO_SMARTCAST!>i<!>)
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T: Any> joinT(x: Int, vararg a: T): T? {
|
||||
return null
|
||||
}
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Int, vararg <!UNUSED_PARAMETER!>a<!>: T): T? {
|
||||
return null
|
||||
}
|
||||
@@ -14,4 +16,4 @@ fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Comparable<*>, <!UNUSED_PARAMETER!>
|
||||
fun test() {
|
||||
val x2 = <!OI;TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>joinT<!>(<!TYPE_MISMATCH!>Unit<!>, "2")
|
||||
checkSubtype<String?>(x2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package h
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T) : T = t
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package h
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T) : T = t
|
||||
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l")
|
||||
@@ -12,4 +14,4 @@ fun test() {
|
||||
checkSubtype<Int>(q)
|
||||
|
||||
foo({}, emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> emptyList(): List<T> = throw Exception()
|
||||
|
||||
fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l")
|
||||
@@ -12,4 +14,4 @@ fun test() {
|
||||
checkSubtype<Int>(q)
|
||||
|
||||
<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>foo<!>({}, <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package a
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <A> cons(x: A, xs: List<A>): List<A> = xs
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package a
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <A> cons(<!UNUSED_PARAMETER!>x<!>: A, xs: List<A>): List<A> = xs
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ package a
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun foo() {
|
||||
val v = array(1, 2, 3)
|
||||
@@ -32,4 +33,4 @@ fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
|
||||
infix fun <T, R> Array<T>.map(transform : (T) -> R) : List<R> {}
|
||||
|
||||
infix fun <T, R> Iterable<T>.map(transform : (T) -> R) : List<R> {}
|
||||
infix fun <T, R> Iterable<T>.map(transform : (T) -> R) : List<R> {}
|
||||
|
||||
@@ -4,6 +4,7 @@ package a
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun foo() {
|
||||
val v = array(1, 2, 3)
|
||||
@@ -32,4 +33,4 @@ fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
|
||||
infix fun <T, R> Array<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
infix fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
infix fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T, R> Collection<T>.map1(f : (T) -> R) : List<R> {}
|
||||
fun <T, R> java.lang.Iterable<T>.map1(f : (T) -> R) : List<R> {}
|
||||
@@ -21,4 +22,4 @@ fun test1(list: List<Int>) {
|
||||
val res = list.foo()
|
||||
//check res is not of error type
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><String>(res)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -4,6 +4,7 @@ package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T, R> Collection<T>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T, R> <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Iterable<T><!>.map1(<!UNUSED_PARAMETER!>f<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
@@ -21,4 +22,4 @@ fun test1(list: List<Int>) {
|
||||
val res = list.foo()
|
||||
//check res is not of error type
|
||||
checkSubtype<String>(<!TYPE_MISMATCH!>res<!>)
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package aaa
|
||||
|
||||
import checkSubtype
|
||||
|
||||
infix fun <T> T.foo(t: T) = t
|
||||
|
||||
fun <T> id(t: T) = t
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//KT-1029 Wrong type inference
|
||||
package i
|
||||
|
||||
import checkSubtype
|
||||
|
||||
public fun<T> from(yielder: ()->Iterable<T>) : Iterable<T> {
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//KT-1029 Wrong type inference
|
||||
package i
|
||||
|
||||
import checkSubtype
|
||||
|
||||
public fun<T> from(<!UNUSED_PARAMETER!>yielder<!>: ()->Iterable<T>) : Iterable<T> {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package i
|
||||
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
public infix fun<TItem> Iterable<TItem>.where(predicate : (TItem)->Boolean) : ()->Iterable<TItem> {
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package i
|
||||
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
public infix fun<TItem> Iterable<TItem>.where(<!UNUSED_PARAMETER!>predicate<!> : (TItem)->Boolean) : ()->Iterable<TItem> {
|
||||
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun test(numbers: Iterable<Int>) {
|
||||
val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2}
|
||||
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(s)
|
||||
@@ -12,4 +14,4 @@ fun test(numbers: Iterable<Int>) {
|
||||
//from library
|
||||
fun <T, R> Iterable<T>.map(transform : (T) -> R) : List<R> {}
|
||||
|
||||
fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {}
|
||||
fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun test(numbers: Iterable<Int>) {
|
||||
val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2}
|
||||
checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>)
|
||||
@@ -12,4 +14,4 @@ fun test(numbers: Iterable<Int>) {
|
||||
//from library
|
||||
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//+JDK
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> {
|
||||
for (t in this){
|
||||
if (filter(t)){
|
||||
@@ -23,4 +25,4 @@ fun test(result: MutableList<in Any>, collection: MutableCollection<String>, pre
|
||||
}
|
||||
|
||||
//from library
|
||||
fun String.startsWith(prefix: String) : Boolean {}
|
||||
fun String.startsWith(prefix: String) : Boolean {}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//+JDK
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> {
|
||||
for (t in this){
|
||||
if (filter(t)){
|
||||
@@ -23,4 +25,4 @@ fun test(result: MutableList<in Any>, collection: MutableCollection<String>, pre
|
||||
}
|
||||
|
||||
//from library
|
||||
fun String.startsWith(<!UNUSED_PARAMETER!>prefix<!>: String) : Boolean {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun String.startsWith(<!UNUSED_PARAMETER!>prefix<!>: String) : Boolean {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package n
|
||||
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val list = arrayList("foo", "bar") + arrayList("cheese", "wine")
|
||||
@@ -14,4 +15,4 @@ fun test() {
|
||||
|
||||
//from library
|
||||
fun <T> arrayList(vararg values: T) : ArrayList<T> {}
|
||||
operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {}
|
||||
operator fun <T> Iterable<T>.plus(elements: Iterable<T>): List<T> {}
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package n
|
||||
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val list = arrayList("foo", "bar") + arrayList("cheese", "wine")
|
||||
@@ -14,4 +15,4 @@ fun test() {
|
||||
|
||||
//from library
|
||||
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
operator fun <T> Iterable<T>.plus(<!UNUSED_PARAMETER!>elements<!>: Iterable<T>): List<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
operator fun <T> Iterable<T>.plus(<!UNUSED_PARAMETER!>elements<!>: Iterable<T>): List<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//KT-1944 Inference fails on run()
|
||||
package j
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class P {
|
||||
var x : Int = 0
|
||||
private set
|
||||
|
||||
@@ -5,6 +5,7 @@ package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val sample1: List<List<Int?>> = arrayList(arrayList<Int?>(1, 7, null, 8))
|
||||
|
||||
@@ -5,6 +5,7 @@ package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val sample1: List<List<Int?>> = arrayList(arrayList<Int?>(1, 7, null, 8))
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
//KT-2200 array(array()) breaks compiler
|
||||
package n
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val a = array(array())
|
||||
@@ -15,4 +16,4 @@ fun main() {
|
||||
|
||||
//from library
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
//KT-2200 array(array()) breaks compiler
|
||||
package n
|
||||
import checkSubtype
|
||||
|
||||
fun main() {
|
||||
val <!UNUSED_VARIABLE!>a<!> = <!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>array<!>(<!NI;NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, OI;TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>array<!>())
|
||||
@@ -15,4 +16,4 @@ fun main() {
|
||||
|
||||
//from library
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
fun <T> array(vararg t : T) : Array<T> = t as Array<T>
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
//KT-2294 Type inference infers DONT_CARE instead of correct type
|
||||
package a
|
||||
import checkSubtype
|
||||
|
||||
public fun <E> foo(array: Array<E>): Array<E> = array
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> {
|
||||
val result = arrayList<K>()
|
||||
|
||||
@@ -5,6 +5,7 @@ package i
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> {
|
||||
val result = arrayList<K>()
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package n
|
||||
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) })
|
||||
@@ -15,4 +16,4 @@ fun <T> arrayList(vararg values: T) : ArrayList<T> {}
|
||||
|
||||
fun <T, R> Collection<T>.map(transform : (T) -> R) : List<R> {}
|
||||
|
||||
fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {}
|
||||
fun <T> Iterable<T>.fold(initial: T, operation: (T, T) -> T): T {}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
package n
|
||||
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) })
|
||||
@@ -15,4 +16,4 @@ fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_
|
||||
|
||||
fun <T, R> Collection<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
fun <T> Iterable<T>.fold(<!UNUSED_PARAMETER!>initial<!>: T, <!UNUSED_PARAMETER!>operation<!>: (T, T) -> T): T {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
interface MyType {}
|
||||
class MyClass<T> : MyType {}
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//KT-731 Missing error from type inference
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A<T>(x: T) {
|
||||
val p = x
|
||||
}
|
||||
@@ -16,4 +18,4 @@ fun main() {
|
||||
val a = A(1)
|
||||
val t: String = a.foo({p -> p})
|
||||
checkSubtype<String>(t)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//KT-731 Missing error from type inference
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A<T>(x: T) {
|
||||
val p = x
|
||||
}
|
||||
@@ -16,4 +18,4 @@ fun main() {
|
||||
val a = A(1)
|
||||
val t: String = <!NI;TYPE_MISMATCH!>a.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>foo({p -> <!TYPE_MISMATCH!>p<!>})<!><!>
|
||||
checkSubtype<String>(t)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ package maze
|
||||
//+JDK
|
||||
import java.util.Collections.*
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun foo(lines: List<String>) {
|
||||
val w = max(lines, comparator {o1, o2 ->
|
||||
@@ -19,4 +20,4 @@ fun foo(lines: List<String>) {
|
||||
//standard library
|
||||
fun <T : Any> T?.sure() : T = this!!
|
||||
|
||||
public inline fun <T> comparator(fn: (T,T) -> Int): Comparator<T> {}
|
||||
public inline fun <T> comparator(fn: (T,T) -> Int): Comparator<T> {}
|
||||
|
||||
@@ -6,6 +6,7 @@ package maze
|
||||
//+JDK
|
||||
import java.util.Collections.*
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun foo(lines: List<String>) {
|
||||
val w = max(lines, comparator {o1, o2 ->
|
||||
@@ -19,4 +20,4 @@ fun foo(lines: List<String>) {
|
||||
//standard library
|
||||
fun <T : Any> T?.sure() : T = this!!
|
||||
|
||||
public inline fun <T> comparator(<!UNUSED_PARAMETER!>fn<!>: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
public inline fun <T> comparator(<!UNUSED_PARAMETER!>fn<!>: (T,T) -> Int): Comparator<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package a
|
||||
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> emptyList() : List<T>? = ArrayList<T>()
|
||||
|
||||
@@ -20,4 +21,4 @@ fun foo() {
|
||||
doWithList(emptyList()!!)
|
||||
}
|
||||
|
||||
fun doWithList(list: List<Int>) = list
|
||||
fun doWithList(list: List<Int>) = list
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package a
|
||||
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> emptyList() : List<T>? = ArrayList<T>()
|
||||
|
||||
@@ -20,4 +21,4 @@ fun foo() {
|
||||
doWithList(emptyList()!!)
|
||||
}
|
||||
|
||||
fun doWithList(list: List<Int>) = list
|
||||
fun doWithList(list: List<Int>) = list
|
||||
|
||||
Vendored
+3
@@ -4,6 +4,9 @@
|
||||
package g
|
||||
|
||||
import java.util.HashSet
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun <T, C: Collection<T>> convert(src: Collection<T>, dest: C): C = throw Exception("$src $dest")
|
||||
|
||||
fun test(l: List<Int>) {
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package s
|
||||
|
||||
import checkSubtype
|
||||
|
||||
interface In<in T>
|
||||
|
||||
interface A
|
||||
@@ -30,4 +32,4 @@ fun test(inA: In<A>) {
|
||||
checkSubtype<C>(r)
|
||||
}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package s
|
||||
|
||||
import checkSubtype
|
||||
|
||||
interface In<in T>
|
||||
|
||||
interface A
|
||||
@@ -30,4 +32,4 @@ fun test(inA: In<A>) {
|
||||
checkSubtype<C>(r)
|
||||
}
|
||||
|
||||
fun use(vararg a: Any?) = a
|
||||
fun use(vararg a: Any?) = a
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//KT-2394 java.lang.Iterable<T> should be visible as kotlin.Iterable<out T>
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun foo(iterable: Iterable<Int>, iterator: Iterator<Int>, comparable: Comparable<Any>) {
|
||||
checkSubtype<Iterable<Any>>(iterable)
|
||||
checkSubtype<Iterator<Any>>(iterator)
|
||||
|
||||
+3
-1
@@ -5,6 +5,8 @@ package a
|
||||
import java.util.Iterator
|
||||
import java.lang.Comparable as Comp
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun bar(any: Any): java.lang.Iterable<Int>? {
|
||||
val a: java.lang.Comparable<String>? = null
|
||||
val b: Iterable<Integer>
|
||||
@@ -15,4 +17,4 @@ fun bar(any: Any): java.lang.Iterable<Int>? {
|
||||
}
|
||||
any as Iterator<*>
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -5,6 +5,8 @@ package a
|
||||
import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util.Iterator<!>
|
||||
import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<!> as Comp
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun bar(any: Any): <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Iterable<Int><!>? {
|
||||
val <!UNUSED_VARIABLE!>a<!>: <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<String><!>? = null
|
||||
val <!UNUSED_VARIABLE!>b<!>: Iterable<<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Integer<!>>
|
||||
@@ -15,4 +17,4 @@ fun bar(any: Any): <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Iterable<Int><!>
|
||||
}
|
||||
any as <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Iterator<*><!>
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//KT-1778 Automatically cast error
|
||||
package kt1778
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val x = checkSubtype<Any>(args[0])
|
||||
if(x is java.lang.CharSequence) {
|
||||
@@ -9,4 +11,4 @@ fun main(args : Array<String>) {
|
||||
if ("a" == x || "b" == x) x.<!UNRESOLVED_REFERENCE!>length<!> else x.length() // <– THEN ERROR
|
||||
if ("a" == x && "a" == x) x.<!UNRESOLVED_REFERENCE!>length<!> else x.length() // <– ELSE ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
//KT-1778 Automatically cast error
|
||||
package kt1778
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val x = checkSubtype<Any>(args[0])
|
||||
if(x is <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.CharSequence<!>) {
|
||||
@@ -9,4 +11,4 @@ fun main(args : Array<String>) {
|
||||
if ("a" == x || "b" == x) <!DEBUG_INFO_SMARTCAST!>x<!>.length else <!DEBUG_INFO_SMARTCAST!>x<!>.length() // <– THEN ERROR
|
||||
if ("a" == x && "a" == x) <!DEBUG_INFO_SMARTCAST!>x<!>.length else <!DEBUG_INFO_SMARTCAST!>x<!>.length() // <– ELSE ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//KT-2176 non-nullability is not inferred after !! or "as"
|
||||
package kt2176
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun f1(a: String?) {
|
||||
a!!
|
||||
checkSubtype<String>(a)
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//KT-2176 non-nullability is not inferred after !! or "as"
|
||||
package kt2176
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun f1(a: String?) {
|
||||
a!!
|
||||
checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
//KT-2234 'period!!' has type Int?
|
||||
|
||||
class Pair<A, B>(val a: A, val b: B)
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
//KT-2234 'period!!' has type Int?
|
||||
|
||||
class Pair<A, B>(val a: A, val b: B)
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, t2: T): T = t1
|
||||
@@ -20,4 +22,4 @@ fun test() {
|
||||
checkSubtype<Any>(d)
|
||||
|
||||
val e: Float = id(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1
|
||||
@@ -20,4 +22,4 @@ fun test() {
|
||||
checkSubtype<Any>(d)
|
||||
|
||||
val <!UNUSED_VARIABLE!>e<!>: Float = <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>id(1)<!>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// !CHECK_TYPE
|
||||
package a
|
||||
|
||||
import checkType
|
||||
import _
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, t2: T): T = t1
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
// !CHECK_TYPE
|
||||
package a
|
||||
|
||||
import checkType
|
||||
import _
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1
|
||||
|
||||
+4
-1
@@ -3,7 +3,10 @@
|
||||
// !CHECK_TYPE
|
||||
package ppp
|
||||
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun foo(f: ft<Int, Int?>) {
|
||||
f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int?>() }
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -3,7 +3,10 @@
|
||||
// !CHECK_TYPE
|
||||
package ppp
|
||||
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun foo(f: ft<Int, Int?>) {
|
||||
f.checkType { _<Int>() }
|
||||
f.checkType { _<Int?>() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@ public abstract class AbstractModule<S> {
|
||||
package module2
|
||||
|
||||
import module1.*
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun <T> javaClass(): Class<T> = null!!
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ public abstract class AbstractModule<S> {
|
||||
package module2
|
||||
|
||||
import module1.*
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun <T> javaClass(): Class<T> = null!!
|
||||
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> two(u: T, v: T): T = u
|
||||
@@ -58,4 +60,4 @@ fun rr(s: String?) {
|
||||
//from library
|
||||
fun <T> arrayListOf(vararg values: T): MutableList<T> = throw Exception()
|
||||
|
||||
fun use(vararg a: Any) = a
|
||||
fun use(vararg a: Any) = a
|
||||
|
||||
+3
-1
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> two(u: T, <!UNUSED_PARAMETER!>v<!>: T): T = u
|
||||
@@ -58,4 +60,4 @@ fun rr(s: String?) {
|
||||
//from library
|
||||
fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>values<!>: T): MutableList<T> = throw Exception()
|
||||
|
||||
fun use(vararg a: Any) = a
|
||||
fun use(vararg a: Any) = a
|
||||
|
||||
+5
@@ -3,6 +3,9 @@
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
import checkType
|
||||
import _
|
||||
|
||||
class B(x: String)
|
||||
typealias A1 = B
|
||||
private typealias A2 = B
|
||||
@@ -18,6 +21,8 @@ fun bar() {
|
||||
package usage
|
||||
|
||||
import a.B
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun baz() {
|
||||
a.A1("") // resolved to B constructor, OK
|
||||
|
||||
+5
@@ -3,6 +3,9 @@
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
import checkType
|
||||
import _
|
||||
|
||||
class B(x: String)
|
||||
typealias A1 = B
|
||||
private typealias A2 = B
|
||||
@@ -18,6 +21,8 @@ fun bar() {
|
||||
package usage
|
||||
|
||||
import a.B
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun baz() {
|
||||
a.A1("") // resolved to B constructor, OK
|
||||
|
||||
Reference in New Issue
Block a user