[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:
Dmitriy Novozhilov
2020-11-12 17:45:40 +03:00
parent 653b26174b
commit 419f54259c
91 changed files with 269 additions and 111 deletions
@@ -6,14 +6,14 @@ FILE: main.kt
^ Int(1) ^ Int(1)
} }
public final fun bar(a: R|A|): R|kotlin/Unit| { public final fun bar(a: R|A|): R|kotlin/Unit| {
R|<local>/a|.R|/foo|.R|tests/_checkType/checkType|<R|kotlin/Int|>(checkType@fun R|tests/_checkType/Inv<kotlin/Int>|.<anonymous>(): R|kotlin/Unit| { R|<local>/a|.R|/foo|.R|/checkType|<R|kotlin/Int|>(checkType@fun R|CheckTypeInv<kotlin/Int>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/Int|>() this@R|special/anonymous|.R|/_|<R|kotlin/Int|>()
} }
) )
} }
public final fun R|JavaClass|.bar(a: R|A|): R|kotlin/Unit| { public final fun R|JavaClass|.bar(a: R|A|): R|kotlin/Unit| {
R|<local>/a|.R|/foo|.R|tests/_checkType/checkType|<R|kotlin/Int|>(checkType@fun R|tests/_checkType/Inv<kotlin/Int>|.<anonymous>(): R|kotlin/Unit| { R|<local>/a|.R|/foo|.R|/checkType|<R|kotlin/Int|>(checkType@fun R|CheckTypeInv<kotlin/Int>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/Int|>() this@R|special/anonymous|.R|/_|<R|kotlin/Int|>()
} }
) )
} }
@@ -21,13 +21,13 @@ FILE: CHECK_TYPE.kt
public final fun <T> checkSubtype(t: R|T|): R|T| { public final fun <T> checkSubtype(t: R|T|): R|T| {
^checkSubtype R|<local>/t| ^checkSubtype R|<local>/t|
} }
public final class Inv<T> : R|kotlin/Any| { public final class CheckTypeInv<T> : R|kotlin/Any| {
public constructor<T>(): R|tests/_checkType/Inv<T>| { public constructor<T>(): R|CheckTypeInv<T>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
} }
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| { public final fun <E> R|CheckTypeInv<E>|._(): R|kotlin/Unit| {
} }
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| { public final infix fun <T> R|T|.checkType(f: R|CheckTypeInv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
} }
@@ -17,8 +17,8 @@ FILE: lambdaArgInScopeFunction.kt
^ R|<local>/it| ^ R|<local>/it|
} }
) } ) }
R|<local>/value|.R|tests/_checkType/checkType|<R|KotlinClass?|>(<L> = checkType@fun R|tests/_checkType/Inv<KotlinClass?>|.<anonymous>(): R|kotlin/Unit| { R|<local>/value|.R|/checkType|<R|KotlinClass?|>(<L> = checkType@fun R|CheckTypeInv<KotlinClass?>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|KotlinClass?|>() this@R|special/anonymous|.R|/_|<R|KotlinClass?|>()
} }
) )
lval lambda: R|() -> KotlinClass| = R|<local>/kotlinClass|?.{ $subj$.R|kotlin/let|<R|KotlinClass|, R|() -> KotlinClass|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|() -> KotlinClass| <kind=EXACTLY_ONCE> { lval lambda: R|() -> KotlinClass| = R|<local>/kotlinClass|?.{ $subj$.R|kotlin/let|<R|KotlinClass|, R|() -> KotlinClass|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|() -> KotlinClass| <kind=EXACTLY_ONCE> {
@@ -28,8 +28,8 @@ FILE: lambdaArgInScopeFunction.kt
} }
) } ) }
R|<local>/lambda|.R|tests/_checkType/checkType|<R|() -> KotlinClass|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function0<KotlinClass>?>|.<anonymous>(): R|kotlin/Unit| { R|<local>/lambda|.R|/checkType|<R|() -> KotlinClass|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function0<KotlinClass>?>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Unit) -> KotlinClass?|>() this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Unit) -> KotlinClass?|>()
} }
) )
} }
@@ -38,8 +38,8 @@ FILE: lambdaArgInScopeFunction.kt
^ R|<local>/it| ^ R|<local>/it|
} }
) )
R|<local>/value|.R|tests/_checkType/checkType|<R|KotlinClass|>(<L> = checkType@fun R|tests/_checkType/Inv<KotlinClass>|.<anonymous>(): R|kotlin/Unit| { R|<local>/value|.R|/checkType|<R|KotlinClass|>(<L> = checkType@fun R|CheckTypeInv<KotlinClass>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|KotlinClass|>() this@R|special/anonymous|.R|/_|<R|KotlinClass|>()
} }
) )
lval lambda: R|() -> KotlinClass| = R|<local>/kotlinClass|.R|kotlin/let|<R|KotlinClass|, R|() -> KotlinClass|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|() -> KotlinClass| <kind=EXACTLY_ONCE> { lval lambda: R|() -> KotlinClass| = R|<local>/kotlinClass|.R|kotlin/let|<R|KotlinClass|, R|() -> KotlinClass|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|() -> KotlinClass| <kind=EXACTLY_ONCE> {
@@ -49,8 +49,8 @@ FILE: lambdaArgInScopeFunction.kt
} }
) )
R|<local>/lambda|.R|tests/_checkType/checkType|<R|() -> KotlinClass|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function0<KotlinClass>>|.<anonymous>(): R|kotlin/Unit| { R|<local>/lambda|.R|/checkType|<R|() -> KotlinClass|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function0<KotlinClass>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Unit) -> KotlinClass?|>() this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Unit) -> KotlinClass?|>()
} }
) )
} }
@@ -58,13 +58,13 @@ FILE: CHECK_TYPE.kt
public final fun <T> checkSubtype(t: R|T|): R|T| { public final fun <T> checkSubtype(t: R|T|): R|T| {
^checkSubtype R|<local>/t| ^checkSubtype R|<local>/t|
} }
public final class Inv<T> : R|kotlin/Any| { public final class CheckTypeInv<T> : R|kotlin/Any| {
public constructor<T>(): R|tests/_checkType/Inv<T>| { public constructor<T>(): R|CheckTypeInv<T>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
} }
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| { public final fun <E> R|CheckTypeInv<E>|._(): R|kotlin/Unit| {
} }
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| { public final infix fun <T> R|T|.checkType(f: R|CheckTypeInv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
} }
@@ -24,16 +24,16 @@ FILE: KotlinClass.kt
} }
} }
R|<local>/validType|.R|tests/_checkType/checkType|<R|(JavaClass) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<JavaClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| { R|<local>/validType|.R|/checkType|<R|(JavaClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<JavaClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|(JavaClass) -> kotlin/Boolean|>() this@R|special/anonymous|.R|/_|<R|(JavaClass) -> kotlin/Boolean|>()
} }
) )
R|<local>/invalidType|.R|tests/_checkType/checkType|<R|(JavaClass) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<JavaClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| { R|<local>/invalidType|.R|/checkType|<R|(JavaClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<JavaClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>() this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
} }
) )
R|/Case1.Case1|(R|<local>/javaClass|).R|/Case1.x|.R|tests/_checkType/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| { R|/Case1.Case1|(R|<local>/javaClass|).R|/Case1.x|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>() this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
} }
) )
} }
@@ -117,16 +117,16 @@ FILE: KotlinClass.kt
} }
} }
R|<local>/validType|.R|tests/_checkType/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| { R|<local>/validType|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|(KotlinClass) -> kotlin/Boolean|>() this@R|special/anonymous|.R|/_|<R|(KotlinClass) -> kotlin/Boolean|>()
} }
) )
R|<local>/invalidType|.R|tests/_checkType/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| { R|<local>/invalidType|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>() this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
} }
) )
R|/Case2.Case2|(R|<local>/kotlinClass|).R|/Case2.x|.R|tests/_checkType/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| { R|/Case2.Case2|(R|<local>/kotlinClass|).R|/Case2.x|.R|/checkType|<R|(KotlinClass) -> kotlin/Boolean|>(<L> = checkType@fun R|CheckTypeInv<kotlin/Function1<KotlinClass, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>() this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
} }
) )
} }
@@ -176,13 +176,13 @@ FILE: CHECK_TYPE.kt
public final fun <T> checkSubtype(t: R|T|): R|T| { public final fun <T> checkSubtype(t: R|T|): R|T| {
^checkSubtype R|<local>/t| ^checkSubtype R|<local>/t|
} }
public final class Inv<T> : R|kotlin/Any| { public final class CheckTypeInv<T> : R|kotlin/Any| {
public constructor<T>(): R|tests/_checkType/Inv<T>| { public constructor<T>(): R|CheckTypeInv<T>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
} }
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| { public final fun <E> R|CheckTypeInv<E>|._(): R|kotlin/Unit| {
} }
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| { public final infix fun <T> R|T|.checkType(f: R|CheckTypeInv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
} }
@@ -201,13 +201,13 @@ FILE: CHECK_TYPE.kt
public final fun <T> checkSubtype(t: R|T|): R|T| { public final fun <T> checkSubtype(t: R|T|): R|T| {
^checkSubtype R|<local>/t| ^checkSubtype R|<local>/t|
} }
public final class Inv<T> : R|kotlin/Any| { public final class CheckTypeInv<T> : R|kotlin/Any| {
public constructor<T>(): R|tests/_checkType/Inv<T>| { public constructor<T>(): R|CheckTypeInv<T>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
} }
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| { public final fun <E> R|CheckTypeInv<E>|._(): R|kotlin/Unit| {
} }
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| { public final infix fun <T> R|T|.checkType(f: R|CheckTypeInv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
} }
@@ -30,43 +30,43 @@ FILE: simpleMostSpecific.kt
public abstract interface D3 : R|A|, R|C| { public abstract interface D3 : R|A|, R|C| {
} }
public final fun main(d1: R|D1|, d2: R|D2|, d3: R|D3|): R|kotlin/Unit| { public final fun main(d1: R|D1|, d2: R|D2|, d3: R|D3|): R|kotlin/Unit| {
R|<local>/d1|.R|/B.x|.R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d1|.R|/B.x|.R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d1|.R|/B.x| = String() R|<local>/d1|.R|/B.x| = String()
R|<local>/d1|.R|/B.foo|().R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d1|.R|/B.foo|().R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d1|.R|/B.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d1|.R|/B.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d2|.R|/B.x|.R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d2|.R|/B.x|.R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d2|.R|/B.x| = String() R|<local>/d2|.R|/B.x| = String()
R|<local>/d2|.R|/B.foo|().R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d2|.R|/B.foo|().R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d2|.R|/B.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d2|.R|/B.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d3|.R|/C.x|.R|tests/_checkType/checkType|<R|kotlin/String|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d3|.R|/C.x|.R|/checkType|<R|kotlin/String|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>() this@R|special/anonymous|.R|/_|<R|kotlin/String|>()
} }
) )
R|<local>/d3|.R|/C.x| = String() R|<local>/d3|.R|/C.x| = String()
R|<local>/d3|.R|/A.foo|().R|tests/_checkType/checkType|<R|kotlin/String?|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String?>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d3|.R|/A.foo|().R|/checkType|<R|kotlin/String?|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String?>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String?|>() this@R|special/anonymous|.R|/_|<R|kotlin/String?|>()
} }
) )
R|<local>/d3|.R|/A.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|tests/_checkType/checkType|<R|kotlin/String?|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/String?>|.<anonymous>(): R|kotlin/Unit| { R|<local>/d3|.R|/A.bar|<R|kotlin/Int|, R|kotlin/String|>(Int(1), String()).R|/checkType|<R|kotlin/String?|>(<L> = checkType@fun R|CheckTypeInv<kotlin/String?>|.<anonymous>(): R|kotlin/Unit| {
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String?|>() this@R|special/anonymous|.R|/_|<R|kotlin/String?|>()
} }
) )
} }
@@ -74,13 +74,13 @@ FILE: CHECK_TYPE.kt
public final fun <T> checkSubtype(t: R|T|): R|T| { public final fun <T> checkSubtype(t: R|T|): R|T| {
^checkSubtype R|<local>/t| ^checkSubtype R|<local>/t|
} }
public final class Inv<T> : R|kotlin/Any| { public final class CheckTypeInv<T> : R|kotlin/Any| {
public constructor<T>(): R|tests/_checkType/Inv<T>| { public constructor<T>(): R|CheckTypeInv<T>| {
super<R|kotlin/Any|>() super<R|kotlin/Any|>()
} }
} }
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| { public final fun <E> R|CheckTypeInv<E>|._(): R|kotlin/Unit| {
} }
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| { public final infix fun <T> R|T|.checkType(f: R|CheckTypeInv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
} }
+3 -5
View File
@@ -1,7 +1,5 @@
package tests._checkType
fun <T> checkSubtype(t: T) = t fun <T> checkSubtype(t: T) = t
class Inv<T> class CheckTypeInv<T>
fun <E> Inv<E>._() {} fun <E> CheckTypeInv<E>._() {}
infix fun <T> T.checkType(f: Inv<T>.() -> Unit) {} infix fun <T> T.checkType(f: CheckTypeInv<T>.() -> Unit) {}
@@ -3,6 +3,9 @@
package foo package foo
import checkType
import checkSubtype
fun Any.foo() : () -> Unit { fun Any.foo() : () -> Unit {
return {} return {}
} }
@@ -3,6 +3,9 @@
package foo package foo
import checkType
import checkSubtype
fun Any.foo() : () -> Unit { fun Any.foo() : () -> Unit {
return {} return {}
} }
@@ -3,6 +3,8 @@
package test package test
import checkSubtype
class C { class C {
companion object { companion object {
fun foo(): String = "companion" fun foo(): String = "companion"
@@ -3,6 +3,8 @@
package test package test
import checkSubtype
class C { class C {
companion object { companion object {
fun foo(): String = "companion" fun foo(): String = "companion"
@@ -3,6 +3,8 @@
package first package first
import checkSubtype
class A { class A {
fun foo() {} fun foo() {}
fun bar(x: Int) {} fun bar(x: Int) {}
@@ -14,7 +16,7 @@ class A {
package other package other
import kotlin.reflect.* import kotlin.reflect.*
import checkSubtype
import first.A import first.A
fun main() { fun main() {
@@ -3,6 +3,8 @@
package first package first
import checkSubtype
class A { class A {
fun foo() {} fun foo() {}
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {} fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
@@ -14,7 +16,7 @@ class A {
package other package other
import kotlin.reflect.* import kotlin.reflect.*
import checkSubtype
import first.A import first.A
fun main() { fun main() {
@@ -4,6 +4,8 @@
package first package first
import checkSubtype
class A class A
fun A.foo() {} fun A.foo() {}
@@ -18,6 +20,7 @@ import kotlin.reflect.KFunction1
import first.A import first.A
import first.foo import first.foo
import checkSubtype
fun main() { fun main() {
val x = first.A::foo val x = first.A::foo
@@ -4,6 +4,8 @@
package first package first
import checkSubtype
class A class A
fun A.foo() {} fun A.foo() {}
@@ -18,6 +20,7 @@ import kotlin.reflect.KFunction1
import first.A import first.A
import first.foo import first.foo
import checkSubtype
fun main() { fun main() {
val x = first.A::foo val x = first.A::foo
@@ -3,6 +3,8 @@
package first package first
import checkSubtype
fun foo() {} fun foo() {}
fun bar(x: Int) {} fun bar(x: Int) {}
fun baz() = "OK" fun baz() = "OK"
@@ -16,6 +18,7 @@ import kotlin.reflect.*
import first.foo import first.foo
import first.bar import first.bar
import first.baz import first.baz
import checkSubtype
fun main() { fun main() {
val x = ::foo val x = ::foo
@@ -3,6 +3,8 @@
package first package first
import checkSubtype
fun foo() {} fun foo() {}
fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {} fun bar(<!UNUSED_PARAMETER!>x<!>: Int) {}
fun baz() = "OK" fun baz() = "OK"
@@ -16,6 +18,7 @@ import kotlin.reflect.*
import first.foo import first.foo
import first.bar import first.bar
import first.baz import first.baz
import checkSubtype
fun main() { fun main() {
val x = ::foo val x = ::foo
@@ -3,6 +3,8 @@
//KT-2631 Check multiple assignment //KT-2631 Check multiple assignment
package a package a
import checkSubtype
class MyClass { class MyClass {
operator fun component1() = 1 operator fun component1() = 1
operator fun component2() = "a" operator fun component2() = "a"
@@ -24,4 +26,4 @@ fun test(mc1: MyClass, mc2: MyClass2) {
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(a) <!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(a)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(b) <!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(b)
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(c) <!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Boolean>(c)
} }
@@ -3,6 +3,8 @@
//KT-2631 Check multiple assignment //KT-2631 Check multiple assignment
package a package a
import checkSubtype
class MyClass { class MyClass {
operator fun component1() = 1 operator fun component1() = 1
operator fun component2() = "a" operator fun component2() = "a"
@@ -24,4 +26,4 @@ fun test(mc1: MyClass, mc2: MyClass2) {
checkSubtype<Boolean>(<!TYPE_MISMATCH!>a<!>) checkSubtype<Boolean>(<!TYPE_MISMATCH!>a<!>)
checkSubtype<Boolean>(<!TYPE_MISMATCH!>b<!>) checkSubtype<Boolean>(<!TYPE_MISMATCH!>b<!>)
checkSubtype<Boolean>(<!TYPE_MISMATCH!>c<!>) checkSubtype<Boolean>(<!TYPE_MISMATCH!>c<!>)
} }
@@ -3,6 +3,8 @@
package m package m
import checkSubtype
fun test(i: Int?) { fun test(i: Int?) {
if (i != null) { if (i != null) {
foo(l1@ i) foo(l1@ i)
@@ -3,6 +3,8 @@
package m package m
import checkSubtype
fun test(i: Int?) { fun test(i: Int?) {
if (i != null) { if (i != null) {
foo(<!REDUNDANT_LABEL_WARNING!>l1@<!> <!DEBUG_INFO_SMARTCAST!>i<!>) foo(<!REDUNDANT_LABEL_WARNING!>l1@<!> <!DEBUG_INFO_SMARTCAST!>i<!>)
@@ -3,6 +3,8 @@
package d package d
import checkSubtype
fun <T: Any> joinT(x: Int, vararg a: T): T? { fun <T: Any> joinT(x: Int, vararg a: T): T? {
return null return null
} }
@@ -3,6 +3,8 @@
package d package d
import checkSubtype
fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Int, vararg <!UNUSED_PARAMETER!>a<!>: T): T? { fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Int, vararg <!UNUSED_PARAMETER!>a<!>: T): T? {
return null return null
} }
@@ -14,4 +16,4 @@ fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Comparable<*>, <!UNUSED_PARAMETER!>
fun test() { fun test() {
val x2 = <!OI;TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>joinT<!>(<!TYPE_MISMATCH!>Unit<!>, "2") val x2 = <!OI;TYPE_INFERENCE_PARAMETER_CONSTRAINT_ERROR!>joinT<!>(<!TYPE_MISMATCH!>Unit<!>, "2")
checkSubtype<String?>(x2) checkSubtype<String?>(x2)
} }
@@ -3,6 +3,7 @@
package h package h
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <T> id(t: T) : T = t fun <T> id(t: T) : T = t
@@ -3,6 +3,7 @@
package h package h
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <T> id(t: T) : T = t fun <T> id(t: T) : T = t
@@ -3,6 +3,8 @@
package a package a
import checkSubtype
fun <T> emptyList(): List<T> = throw Exception() fun <T> emptyList(): List<T> = throw Exception()
fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l") fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l")
@@ -12,4 +14,4 @@ fun test() {
checkSubtype<Int>(q) checkSubtype<Int>(q)
foo({}, emptyList()) foo({}, emptyList())
} }
@@ -3,6 +3,8 @@
package a package a
import checkSubtype
fun <T> emptyList(): List<T> = throw Exception() fun <T> emptyList(): List<T> = throw Exception()
fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l") fun <T> foo(f: T.() -> Unit, l: List<T>): T = throw Exception("$f$l")
@@ -12,4 +14,4 @@ fun test() {
checkSubtype<Int>(q) 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<!>()) <!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 package a
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <A> cons(x: A, xs: List<A>): List<A> = xs fun <A> cons(x: A, xs: List<A>): List<A> = xs
@@ -3,6 +3,7 @@
package a package a
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <A> cons(<!UNUSED_PARAMETER!>x<!>: A, xs: List<A>): List<A> = xs fun <A> cons(<!UNUSED_PARAMETER!>x<!>: A, xs: List<A>): List<A> = xs
@@ -4,6 +4,7 @@ package a
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun foo() { fun foo() {
val v = array(1, 2, 3) 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> 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 //+JDK
import java.util.* import java.util.*
import checkSubtype
fun foo() { fun foo() {
val v = array(1, 2, 3) 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> 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!>}<!>
@@ -4,6 +4,7 @@ package i
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <T, R> Collection<T>.map1(f : (T) -> R) : List<R> {} fun <T, R> Collection<T>.map1(f : (T) -> R) : List<R> {}
fun <T, R> java.lang.Iterable<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() val res = list.foo()
//check res is not of error type //check res is not of error type
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><String>(res) <!INAPPLICABLE_CANDIDATE!>checkSubtype<!><String>(res)
} }
@@ -4,6 +4,7 @@ package i
//+JDK //+JDK
import java.util.* 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> 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!>}<!> 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() val res = list.foo()
//check res is not of error type //check res is not of error type
checkSubtype<String>(<!TYPE_MISMATCH!>res<!>) checkSubtype<String>(<!TYPE_MISMATCH!>res<!>)
} }
@@ -3,6 +3,8 @@
package aaa package aaa
import checkSubtype
infix fun <T> T.foo(t: T) = t infix fun <T> T.foo(t: T) = t
fun <T> id(t: T) = t fun <T> id(t: T) = t
@@ -3,6 +3,8 @@
//KT-1029 Wrong type inference //KT-1029 Wrong type inference
package i package i
import checkSubtype
public fun<T> from(yielder: ()->Iterable<T>) : Iterable<T> { public fun<T> from(yielder: ()->Iterable<T>) : Iterable<T> {
} }
@@ -3,6 +3,8 @@
//KT-1029 Wrong type inference //KT-1029 Wrong type inference
package i package i
import checkSubtype
public fun<T> from(<!UNUSED_PARAMETER!>yielder<!>: ()->Iterable<T>) : Iterable<T> { public fun<T> from(<!UNUSED_PARAMETER!>yielder<!>: ()->Iterable<T>) : Iterable<T> {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
@@ -4,6 +4,7 @@
package i package i
import java.util.ArrayList import java.util.ArrayList
import checkSubtype
public infix fun<TItem> Iterable<TItem>.where(predicate : (TItem)->Boolean) : ()->Iterable<TItem> { public infix fun<TItem> Iterable<TItem>.where(predicate : (TItem)->Boolean) : ()->Iterable<TItem> {
} }
@@ -4,6 +4,7 @@
package i package i
import java.util.ArrayList import java.util.ArrayList
import checkSubtype
public infix fun<TItem> Iterable<TItem>.where(<!UNUSED_PARAMETER!>predicate<!> : (TItem)->Boolean) : ()->Iterable<TItem> { public infix fun<TItem> Iterable<TItem>.where(<!UNUSED_PARAMETER!>predicate<!> : (TItem)->Boolean) : ()->Iterable<TItem> {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!> <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!>
@@ -4,6 +4,8 @@
package d package d
import checkSubtype
fun test(numbers: Iterable<Int>) { fun test(numbers: Iterable<Int>) {
val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2} val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2}
<!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(s) <!INAPPLICABLE_CANDIDATE!>checkSubtype<!><Int>(s)
@@ -12,4 +14,4 @@ fun test(numbers: Iterable<Int>) {
//from library //from library
fun <T, R> Iterable<T>.map(transform : (T) -> R) : List<R> {} 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 package d
import checkSubtype
fun test(numbers: Iterable<Int>) { fun test(numbers: Iterable<Int>) {
val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2} val s = numbers.map{it.toString()}.fold(""){it, it2 -> it + it2}
checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>) checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>)
@@ -12,4 +14,4 @@ fun test(numbers: Iterable<Int>) {
//from library //from library
fun <T, R> Iterable<T>.map(<!UNUSED_PARAMETER!>transform<!> : (T) -> R) : List<R> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!> 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 //+JDK
package d package d
import checkSubtype
public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> { public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> {
for (t in this){ for (t in this){
if (filter(t)){ if (filter(t)){
@@ -23,4 +25,4 @@ fun test(result: MutableList<in Any>, collection: MutableCollection<String>, pre
} }
//from library //from library
fun String.startsWith(prefix: String) : Boolean {} fun String.startsWith(prefix: String) : Boolean {}
@@ -4,6 +4,8 @@
//+JDK //+JDK
package d package d
import checkSubtype
public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> { public fun <T> MutableCollection<out T>.filterToMy(result : MutableList<in T>, filter : (T) -> Boolean) : MutableCollection<out T> {
for (t in this){ for (t in this){
if (filter(t)){ if (filter(t)){
@@ -23,4 +25,4 @@ fun test(result: MutableList<in Any>, collection: MutableCollection<String>, pre
} }
//from library //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 package n
import java.util.ArrayList import java.util.ArrayList
import checkSubtype
fun test() { fun test() {
val list = arrayList("foo", "bar") + arrayList("cheese", "wine") val list = arrayList("foo", "bar") + arrayList("cheese", "wine")
@@ -14,4 +15,4 @@ fun test() {
//from library //from library
fun <T> arrayList(vararg values: T) : ArrayList<T> {} 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 package n
import java.util.ArrayList import java.util.ArrayList
import checkSubtype
fun test() { fun test() {
val list = arrayList("foo", "bar") + arrayList("cheese", "wine") val list = arrayList("foo", "bar") + arrayList("cheese", "wine")
@@ -14,4 +15,4 @@ fun test() {
//from library //from library
fun <T> arrayList(vararg <!UNUSED_PARAMETER!>values<!>: T) : ArrayList<T> {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>}<!> 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() //KT-1944 Inference fails on run()
package j package j
import checkSubtype
class P { class P {
var x : Int = 0 var x : Int = 0
private set private set
@@ -5,6 +5,7 @@ package i
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun test() { fun test() {
val sample1: List<List<Int?>> = arrayList(arrayList<Int?>(1, 7, null, 8)) val sample1: List<List<Int?>> = arrayList(arrayList<Int?>(1, 7, null, 8))
@@ -5,6 +5,7 @@ package i
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun test() { fun test() {
val sample1: List<List<Int?>> = arrayList(arrayList<Int?>(1, 7, null, 8)) val sample1: List<List<Int?>> = arrayList(arrayList<Int?>(1, 7, null, 8))
@@ -3,6 +3,7 @@
//KT-2200 array(array()) breaks compiler //KT-2200 array(array()) breaks compiler
package n package n
import checkSubtype
fun main() { fun main() {
val a = array(array()) val a = array(array())
@@ -15,4 +16,4 @@ fun main() {
//from library //from library
@Suppress("UNCHECKED_CAST") @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 //KT-2200 array(array()) breaks compiler
package n package n
import checkSubtype
fun main() { 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<!>()) 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 //from library
@Suppress("UNCHECKED_CAST") @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 //KT-2294 Type inference infers DONT_CARE instead of correct type
package a package a
import checkSubtype
public fun <E> foo(array: Array<E>): Array<E> = array public fun <E> foo(array: Array<E>): Array<E> = array
@@ -5,6 +5,7 @@ package i
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> { fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> {
val result = arrayList<K>() val result = arrayList<K>()
@@ -5,6 +5,7 @@ package i
//+JDK //+JDK
import java.util.* import java.util.*
import checkSubtype
fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> { fun <T, K> someFunction(list: List<T>, transform: (T) -> K): List<K> {
val result = arrayList<K>() val result = arrayList<K>()
@@ -3,6 +3,7 @@
package n package n
import java.util.* import java.util.*
import checkSubtype
fun test() { fun test() {
val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) }) 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, 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 package n
import java.util.* import java.util.*
import checkSubtype
fun test() { fun test() {
val foo = arrayList("").map { it -> it.length }.fold(0, { x, y -> Math.max(x, y) }) 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, 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 package a
import checkSubtype
interface MyType {} interface MyType {}
class MyClass<T> : MyType {} class MyClass<T> : MyType {}
@@ -4,6 +4,8 @@
//KT-731 Missing error from type inference //KT-731 Missing error from type inference
package a package a
import checkSubtype
class A<T>(x: T) { class A<T>(x: T) {
val p = x val p = x
} }
@@ -16,4 +18,4 @@ fun main() {
val a = A(1) val a = A(1)
val t: String = a.foo({p -> p}) val t: String = a.foo({p -> p})
checkSubtype<String>(t) checkSubtype<String>(t)
} }
@@ -4,6 +4,8 @@
//KT-731 Missing error from type inference //KT-731 Missing error from type inference
package a package a
import checkSubtype
class A<T>(x: T) { class A<T>(x: T) {
val p = x val p = x
} }
@@ -16,4 +18,4 @@ fun main() {
val a = A(1) val a = A(1)
val t: String = <!NI;TYPE_MISMATCH!>a.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>foo({p -> <!TYPE_MISMATCH!>p<!>})<!><!> val t: String = <!NI;TYPE_MISMATCH!>a.<!OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>foo({p -> <!TYPE_MISMATCH!>p<!>})<!><!>
checkSubtype<String>(t) checkSubtype<String>(t)
} }
@@ -6,6 +6,7 @@ package maze
//+JDK //+JDK
import java.util.Collections.* import java.util.Collections.*
import java.util.* import java.util.*
import checkSubtype
fun foo(lines: List<String>) { fun foo(lines: List<String>) {
val w = max(lines, comparator {o1, o2 -> val w = max(lines, comparator {o1, o2 ->
@@ -19,4 +20,4 @@ fun foo(lines: List<String>) {
//standard library //standard library
fun <T : Any> T?.sure() : T = this!! 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 //+JDK
import java.util.Collections.* import java.util.Collections.*
import java.util.* import java.util.*
import checkSubtype
fun foo(lines: List<String>) { fun foo(lines: List<String>) {
val w = max(lines, comparator {o1, o2 -> val w = max(lines, comparator {o1, o2 ->
@@ -19,4 +20,4 @@ fun foo(lines: List<String>) {
//standard library //standard library
fun <T : Any> T?.sure() : T = this!! 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 package a
import java.util.* import java.util.*
import checkSubtype
fun <T> emptyList() : List<T>? = ArrayList<T>() fun <T> emptyList() : List<T>? = ArrayList<T>()
@@ -20,4 +21,4 @@ fun foo() {
doWithList(emptyList()!!) doWithList(emptyList()!!)
} }
fun doWithList(list: List<Int>) = list fun doWithList(list: List<Int>) = list
@@ -6,6 +6,7 @@
package a package a
import java.util.* import java.util.*
import checkSubtype
fun <T> emptyList() : List<T>? = ArrayList<T>() fun <T> emptyList() : List<T>? = ArrayList<T>()
@@ -20,4 +21,4 @@ fun foo() {
doWithList(emptyList()!!) doWithList(emptyList()!!)
} }
fun doWithList(list: List<Int>) = list fun doWithList(list: List<Int>) = list
@@ -4,6 +4,9 @@
package g package g
import java.util.HashSet import java.util.HashSet
import checkType
import _
fun <T, C: Collection<T>> convert(src: Collection<T>, dest: C): C = throw Exception("$src $dest") fun <T, C: Collection<T>> convert(src: Collection<T>, dest: C): C = throw Exception("$src $dest")
fun test(l: List<Int>) { fun test(l: List<Int>) {
@@ -3,6 +3,8 @@
package s package s
import checkSubtype
interface In<in T> interface In<in T>
interface A interface A
@@ -30,4 +32,4 @@ fun test(inA: In<A>) {
checkSubtype<C>(r) checkSubtype<C>(r)
} }
fun use(vararg a: Any?) = a fun use(vararg a: Any?) = a
@@ -3,6 +3,8 @@
package s package s
import checkSubtype
interface In<in T> interface In<in T>
interface A interface A
@@ -30,4 +32,4 @@ fun test(inA: In<A>) {
checkSubtype<C>(r) checkSubtype<C>(r)
} }
fun use(vararg a: Any?) = a fun use(vararg a: Any?) = a
+2
View File
@@ -4,6 +4,8 @@
//KT-2394 java.lang.Iterable<T> should be visible as kotlin.Iterable<out T> //KT-2394 java.lang.Iterable<T> should be visible as kotlin.Iterable<out T>
package d package d
import checkSubtype
fun foo(iterable: Iterable<Int>, iterator: Iterator<Int>, comparable: Comparable<Any>) { fun foo(iterable: Iterable<Int>, iterator: Iterator<Int>, comparable: Comparable<Any>) {
checkSubtype<Iterable<Any>>(iterable) checkSubtype<Iterable<Any>>(iterable)
checkSubtype<Iterator<Any>>(iterator) checkSubtype<Iterator<Any>>(iterator)
+3 -1
View File
@@ -5,6 +5,8 @@ package a
import java.util.Iterator import java.util.Iterator
import java.lang.Comparable as Comp import java.lang.Comparable as Comp
import checkSubtype
fun bar(any: Any): java.lang.Iterable<Int>? { fun bar(any: Any): java.lang.Iterable<Int>? {
val a: java.lang.Comparable<String>? = null val a: java.lang.Comparable<String>? = null
val b: Iterable<Integer> val b: Iterable<Integer>
@@ -15,4 +17,4 @@ fun bar(any: Any): java.lang.Iterable<Int>? {
} }
any as Iterator<*> any as Iterator<*>
return null return null
} }
+3 -1
View File
@@ -5,6 +5,8 @@ package a
import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util.Iterator<!> import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util.Iterator<!>
import <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<!> as Comp 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><!>? { 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!>a<!>: <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<String><!>? = null
val <!UNUSED_VARIABLE!>b<!>: Iterable<<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Integer<!>> 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<*><!> any as <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Iterator<*><!>
return null return null
} }
@@ -2,6 +2,8 @@
//KT-1778 Automatically cast error //KT-1778 Automatically cast error
package kt1778 package kt1778
import checkSubtype
fun main(args : Array<String>) { fun main(args : Array<String>) {
val x = checkSubtype<Any>(args[0]) val x = checkSubtype<Any>(args[0])
if(x is java.lang.CharSequence) { 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 || "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 if ("a" == x && "a" == x) x.<!UNRESOLVED_REFERENCE!>length<!> else x.length() // < ELSE ERROR
} }
} }
@@ -2,6 +2,8 @@
//KT-1778 Automatically cast error //KT-1778 Automatically cast error
package kt1778 package kt1778
import checkSubtype
fun main(args : Array<String>) { fun main(args : Array<String>) {
val x = checkSubtype<Any>(args[0]) val x = checkSubtype<Any>(args[0])
if(x is <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.CharSequence<!>) { 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 || "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 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" //KT-2176 non-nullability is not inferred after !! or "as"
package kt2176 package kt2176
import checkSubtype
fun f1(a: String?) { fun f1(a: String?) {
a!! a!!
checkSubtype<String>(a) checkSubtype<String>(a)
@@ -3,6 +3,8 @@
//KT-2176 non-nullability is not inferred after !! or "as" //KT-2176 non-nullability is not inferred after !! or "as"
package kt2176 package kt2176
import checkSubtype
fun f1(a: String?) { fun f1(a: String?) {
a!! a!!
checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>a<!>) checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>a<!>)
@@ -2,6 +2,8 @@
package a package a
import checkSubtype
//KT-2234 'period!!' has type Int? //KT-2234 'period!!' has type Int?
class Pair<A, B>(val a: A, val b: B) class Pair<A, B>(val a: A, val b: B)
@@ -2,6 +2,8 @@
package a package a
import checkSubtype
//KT-2234 'period!!' has type Int? //KT-2234 'period!!' has type Int?
class Pair<A, B>(val a: A, val b: B) class Pair<A, B>(val a: A, val b: B)
@@ -3,6 +3,8 @@
package a package a
import checkSubtype
fun <T> id(t: T): T = t fun <T> id(t: T): T = t
fun <T> either(t1: T, t2: T): T = t1 fun <T> either(t1: T, t2: T): T = t1
@@ -20,4 +22,4 @@ fun test() {
checkSubtype<Any>(d) checkSubtype<Any>(d)
val e: Float = id(1) val e: Float = id(1)
} }
@@ -3,6 +3,8 @@
package a package a
import checkSubtype
fun <T> id(t: T): T = t fun <T> id(t: T): T = t
fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1 fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1
@@ -20,4 +22,4 @@ fun test() {
checkSubtype<Any>(d) checkSubtype<Any>(d)
val <!UNUSED_VARIABLE!>e<!>: Float = <!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH, OI;TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>id(1)<!> 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 // !CHECK_TYPE
package a package a
import checkType
import _
import checkSubtype
fun <T> id(t: T): T = t fun <T> id(t: T): T = t
fun <T> either(t1: T, t2: T): T = t1 fun <T> either(t1: T, t2: T): T = t1
@@ -2,6 +2,10 @@
// !CHECK_TYPE // !CHECK_TYPE
package a package a
import checkType
import _
import checkSubtype
fun <T> id(t: T): T = t fun <T> id(t: T): T = t
fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1 fun <T> either(t1: T, <!UNUSED_PARAMETER!>t2<!>: T): T = t1
@@ -3,7 +3,10 @@
// !CHECK_TYPE // !CHECK_TYPE
package ppp package ppp
import checkType
import _
fun foo(f: ft<Int, Int?>) { fun foo(f: ft<Int, Int?>) {
f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() } f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int?>() } f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int?>() }
} }
@@ -3,7 +3,10 @@
// !CHECK_TYPE // !CHECK_TYPE
package ppp package ppp
import checkType
import _
fun foo(f: ft<Int, Int?>) { fun foo(f: ft<Int, Int?>) {
f.checkType { _<Int>() } f.checkType { _<Int>() }
f.checkType { _<Int?>() } f.checkType { _<Int?>() }
} }
@@ -11,6 +11,8 @@ public abstract class AbstractModule<S> {
package module2 package module2
import module1.* import module1.*
import checkType
import _
fun <T> javaClass(): Class<T> = null!! fun <T> javaClass(): Class<T> = null!!
@@ -11,6 +11,8 @@ public abstract class AbstractModule<S> {
package module2 package module2
import module1.* import module1.*
import checkType
import _
fun <T> javaClass(): Class<T> = null!! fun <T> javaClass(): Class<T> = null!!
@@ -3,6 +3,8 @@
package a package a
import checkSubtype
fun <T> id(t: T): T = t fun <T> id(t: T): T = t
fun <T> two(u: T, v: T): T = u fun <T> two(u: T, v: T): T = u
@@ -58,4 +60,4 @@ fun rr(s: String?) {
//from library //from library
fun <T> arrayListOf(vararg values: T): MutableList<T> = throw Exception() fun <T> arrayListOf(vararg values: T): MutableList<T> = throw Exception()
fun use(vararg a: Any) = a fun use(vararg a: Any) = a
@@ -3,6 +3,8 @@
package a package a
import checkSubtype
fun <T> id(t: T): T = t fun <T> id(t: T): T = t
fun <T> two(u: T, <!UNUSED_PARAMETER!>v<!>: T): T = u fun <T> two(u: T, <!UNUSED_PARAMETER!>v<!>: T): T = u
@@ -58,4 +60,4 @@ fun rr(s: String?) {
//from library //from library
fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>values<!>: T): MutableList<T> = throw Exception() fun <T> arrayListOf(vararg <!UNUSED_PARAMETER!>values<!>: T): MutableList<T> = throw Exception()
fun use(vararg a: Any) = a fun use(vararg a: Any) = a
@@ -3,6 +3,9 @@
// FILE: a.kt // FILE: a.kt
package a package a
import checkType
import _
class B(x: String) class B(x: String)
typealias A1 = B typealias A1 = B
private typealias A2 = B private typealias A2 = B
@@ -18,6 +21,8 @@ fun bar() {
package usage package usage
import a.B import a.B
import checkType
import _
fun baz() { fun baz() {
a.A1("") // resolved to B constructor, OK a.A1("") // resolved to B constructor, OK
@@ -3,6 +3,9 @@
// FILE: a.kt // FILE: a.kt
package a package a
import checkType
import _
class B(x: String) class B(x: String)
typealias A1 = B typealias A1 = B
private typealias A2 = B private typealias A2 = B
@@ -18,6 +21,8 @@ fun bar() {
package usage package usage
import a.B import a.B
import checkType
import _
fun baz() { fun baz() {
a.A1("") // resolved to B constructor, OK a.A1("") // resolved to B constructor, OK
@@ -3,6 +3,8 @@
package b package b
import checkSubtype
fun bar() { fun bar() {
val a1 = Array(1, {i: Int -> i}) val a1 = Array(1, {i: Int -> i})
val a2 = Array(1, {i: Int -> "$i"}) val a2 = Array(1, {i: Int -> "$i"})
@@ -3,6 +3,8 @@
//KT-1558 Exception while analyzing //KT-1558 Exception while analyzing
package j package j
import checkSubtype
fun <T : Any> T?.sure() : T = this!! fun <T : Any> T?.sure() : T = this!!
fun <E> List<*>.toArray(ar: Array<E>): Array<E> = ar fun <E> List<*>.toArray(ar: Array<E>): Array<E> = ar
@@ -3,6 +3,8 @@
//KT-1558 Exception while analyzing //KT-1558 Exception while analyzing
package j package j
import checkSubtype
fun <T : Any> T?.sure() : T = this!! fun <T : Any> T?.sure() : T = this!!
fun <E> List<*>.toArray(ar: Array<E>): Array<E> = ar fun <E> List<*>.toArray(ar: Array<E>): Array<E> = ar
@@ -20,6 +20,8 @@ fun A.forEach(s: String) {}
package a package a
import b.* import b.*
import checkType
import _
class A { class A {
fun forEach() = this fun forEach() = this
@@ -20,6 +20,8 @@ fun A.forEach(s: String) {}
package a package a
import b.* import b.*
import checkType
import _
class A { class A {
fun forEach() = this fun forEach() = this
@@ -625,6 +625,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
getTopLevelPackagesFromFileList(getKtFiles(testFiles, false)) getTopLevelPackagesFromFileList(getKtFiles(testFiles, false))
).toSet() ).toSet()
val checkTypeEnabled = testFiles.any { it.declareCheckType }
val stepIntoFilter = Predicate<DeclarationDescriptor> { descriptor -> val stepIntoFilter = Predicate<DeclarationDescriptor> { descriptor ->
val module = DescriptorUtils.getContainingModuleOrNull(descriptor) val module = DescriptorUtils.getContainingModuleOrNull(descriptor)
if (module !in modules) return@Predicate false if (module !in modules) return@Predicate false
@@ -634,6 +635,8 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
return@Predicate fqName.isRoot || fqName.pathSegments().first() in packagesNames return@Predicate fqName.isRoot || fqName.pathSegments().first() in packagesNames
} }
if (checkTypeEnabled && descriptor.name in NAMES_OF_CHECK_TYPE_HELPER) return@Predicate false
true true
} }
@@ -768,5 +771,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
private val HASH_SANITIZER = fun(s: String): String = s.replace("@(\\d)+".toRegex(), "") private val HASH_SANITIZER = fun(s: String): String = s.replace("@(\\d)+".toRegex(), "")
private val MODULE_FILES = ModuleCapability<List<KtFile>>("") private val MODULE_FILES = ModuleCapability<List<KtFile>>("")
private val NAMES_OF_CHECK_TYPE_HELPER = listOf("checkSubtype", "CheckTypeInv", "_", "checkType").map { Name.identifier(it) }
} }
} }
@@ -190,9 +190,6 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
private val imports: String private val imports: String
get() = buildString { get() = buildString {
// Line separator is "\n" intentionally here (see DocumentImpl.assertValidSeparators) // Line separator is "\n" intentionally here (see DocumentImpl.assertValidSeparators)
if (declareCheckType) {
append(CHECK_TYPE_IMPORT + "\n")
}
if (declareFlexibleType) { if (declareFlexibleType) {
append(EXPLICIT_FLEXIBLE_TYPES_IMPORT + "\n") append(EXPLICIT_FLEXIBLE_TYPES_IMPORT + "\n")
} }
@@ -403,8 +400,6 @@ abstract class BaseDiagnosticsTest : KotlinMultiFileTestWithJava<TestModule, Tes
) )
val CHECK_TYPE_DIRECTIVE = "CHECK_TYPE" val CHECK_TYPE_DIRECTIVE = "CHECK_TYPE"
val CHECK_TYPE_PACKAGE = "tests._checkType"
val CHECK_TYPE_IMPORT = "import $CHECK_TYPE_PACKAGE.*"
val EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE = "EXPLICIT_FLEXIBLE_TYPES" val EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE = "EXPLICIT_FLEXIBLE_TYPES"
val EXPLICIT_FLEXIBLE_PACKAGE = InternalFlexibleTypeTransformer.FLEXIBLE_TYPE_CLASSIFIER.packageFqName.asString() val EXPLICIT_FLEXIBLE_PACKAGE = InternalFlexibleTypeTransformer.FLEXIBLE_TYPE_CLASSIFIER.packageFqName.asString()