[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:
+8
-8
@@ -6,14 +6,14 @@ FILE: main.kt
|
||||
^ Int(1)
|
||||
}
|
||||
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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/Int|>()
|
||||
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|/_|<R|kotlin/Int|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/Int|>()
|
||||
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|/_|<R|kotlin/Int|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -21,13 +21,13 @@ FILE: CHECK_TYPE.kt
|
||||
public final fun <T> checkSubtype(t: R|T|): R|T| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
public final class CheckTypeInv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|CheckTypeInv<T>| {
|
||||
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| {
|
||||
}
|
||||
|
||||
+12
-12
@@ -17,8 +17,8 @@ FILE: lambdaArgInScopeFunction.kt
|
||||
^ R|<local>/it|
|
||||
}
|
||||
) }
|
||||
R|<local>/value|.R|tests/_checkType/checkType|<R|KotlinClass?|>(<L> = checkType@fun R|tests/_checkType/Inv<KotlinClass?>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|KotlinClass?|>()
|
||||
R|<local>/value|.R|/checkType|<R|KotlinClass?|>(<L> = checkType@fun R|CheckTypeInv<KotlinClass?>|.<anonymous>(): R|kotlin/Unit| {
|
||||
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> {
|
||||
@@ -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| {
|
||||
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Unit) -> KotlinClass?|>()
|
||||
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): /_>#<R|(kotlin/Unit) -> KotlinClass?|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -38,8 +38,8 @@ FILE: lambdaArgInScopeFunction.kt
|
||||
^ R|<local>/it|
|
||||
}
|
||||
)
|
||||
R|<local>/value|.R|tests/_checkType/checkType|<R|KotlinClass|>(<L> = checkType@fun R|tests/_checkType/Inv<KotlinClass>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|KotlinClass|>()
|
||||
R|<local>/value|.R|/checkType|<R|KotlinClass|>(<L> = checkType@fun R|CheckTypeInv<KotlinClass>|.<anonymous>(): R|kotlin/Unit| {
|
||||
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> {
|
||||
@@ -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| {
|
||||
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Unit) -> KotlinClass?|>()
|
||||
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): /_>#<R|(kotlin/Unit) -> KotlinClass?|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -58,13 +58,13 @@ FILE: CHECK_TYPE.kt
|
||||
public final fun <T> checkSubtype(t: R|T|): R|T| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
public final class CheckTypeInv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|CheckTypeInv<T>| {
|
||||
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| {
|
||||
}
|
||||
|
||||
+16
-16
@@ -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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|(JavaClass) -> kotlin/Boolean|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
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): /_>#<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| {
|
||||
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
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): /_>#<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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|(KotlinClass) -> kotlin/Boolean|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
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): /_>#<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| {
|
||||
this@R|special/anonymous|.<Inapplicable(INAPPLICABLE_WRONG_RECEIVER): tests/_checkType/_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
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): /_>#<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -176,13 +176,13 @@ FILE: CHECK_TYPE.kt
|
||||
public final fun <T> checkSubtype(t: R|T|): R|T| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
public final class CheckTypeInv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|CheckTypeInv<T>| {
|
||||
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| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
public final class CheckTypeInv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|CheckTypeInv<T>| {
|
||||
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| {
|
||||
}
|
||||
|
||||
+22
-22
@@ -30,43 +30,43 @@ FILE: simpleMostSpecific.kt
|
||||
public abstract interface D3 : R|A|, R|C| {
|
||||
}
|
||||
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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<R|kotlin/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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<R|kotlin/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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String|>()
|
||||
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|/_|<R|kotlin/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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String?|>()
|
||||
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|/_|<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| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|kotlin/String?|>()
|
||||
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|/_|<R|kotlin/String?|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -74,13 +74,13 @@ FILE: CHECK_TYPE.kt
|
||||
public final fun <T> checkSubtype(t: R|T|): R|T| {
|
||||
^checkSubtype R|<local>/t|
|
||||
}
|
||||
public final class Inv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|tests/_checkType/Inv<T>| {
|
||||
public final class CheckTypeInv<T> : R|kotlin/Any| {
|
||||
public constructor<T>(): R|CheckTypeInv<T>| {
|
||||
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| {
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package tests._checkType
|
||||
|
||||
fun <T> checkSubtype(t: T) = t
|
||||
class Inv<T>
|
||||
fun <E> Inv<E>._() {}
|
||||
class CheckTypeInv<T>
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
//KT-2631 Check multiple assignment
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class MyClass {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = "a"
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
//KT-2631 Check multiple assignment
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class MyClass {
|
||||
operator fun component1() = 1
|
||||
operator fun component2() = "a"
|
||||
|
||||
+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
|
||||
}
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package d
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T: Any> joinT(<!UNUSED_PARAMETER!>x<!>: Int, vararg <!UNUSED_PARAMETER!>a<!>: T): T? {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -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,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")
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -4,6 +4,7 @@ package a
|
||||
|
||||
//+JDK
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun foo() {
|
||||
val v = array(1, 2, 3)
|
||||
|
||||
+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> {}
|
||||
|
||||
@@ -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!>}<!>
|
||||
|
||||
+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)
|
||||
|
||||
@@ -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<!>)
|
||||
|
||||
@@ -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)){
|
||||
|
||||
@@ -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)){
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package n
|
||||
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val list = arrayList("foo", "bar") + arrayList("cheese", "wine")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
package n
|
||||
|
||||
import java.util.ArrayList
|
||||
import checkSubtype
|
||||
|
||||
fun test() {
|
||||
val list = arrayList("foo", "bar") + arrayList("cheese", "wine")
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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<!>())
|
||||
|
||||
@@ -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) })
|
||||
|
||||
@@ -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) })
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
//KT-731 Missing error from type inference
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
class A<T>(x: T) {
|
||||
val p = x
|
||||
}
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -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 ->
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package a
|
||||
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> emptyList() : List<T>? = ArrayList<T>()
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package a
|
||||
|
||||
import java.util.*
|
||||
import checkSubtype
|
||||
|
||||
fun <T> emptyList() : List<T>? = ArrayList<T>()
|
||||
|
||||
|
||||
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>) {
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package s
|
||||
|
||||
import checkSubtype
|
||||
|
||||
interface In<in T>
|
||||
|
||||
interface A
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package s
|
||||
|
||||
import checkSubtype
|
||||
|
||||
interface In<in T>
|
||||
|
||||
interface 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)
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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<!>>
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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<!>) {
|
||||
|
||||
@@ -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,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> either(t1: T, t2: T): T = t1
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
@@ -3,6 +3,9 @@
|
||||
// !CHECK_TYPE
|
||||
package ppp
|
||||
|
||||
import checkType
|
||||
import _
|
||||
|
||||
fun foo(f: ft<Int, Int?>) {
|
||||
f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
f.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Int?>() }
|
||||
|
||||
+3
@@ -3,6 +3,9 @@
|
||||
// !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!!
|
||||
|
||||
|
||||
+2
@@ -3,6 +3,8 @@
|
||||
|
||||
package a
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T> id(t: T): T = t
|
||||
|
||||
fun <T> two(u: T, v: T): T = u
|
||||
|
||||
@@ -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
|
||||
|
||||
+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
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
package b
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun bar() {
|
||||
val a1 = Array(1, {i: Int -> i})
|
||||
val a2 = Array(1, {i: Int -> "$i"})
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//KT-1558 Exception while analyzing
|
||||
package j
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T : Any> T?.sure() : T = this!!
|
||||
|
||||
fun <E> List<*>.toArray(ar: Array<E>): Array<E> = ar
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
//KT-1558 Exception while analyzing
|
||||
package j
|
||||
|
||||
import checkSubtype
|
||||
|
||||
fun <T : Any> T?.sure() : T = this!!
|
||||
|
||||
fun <E> List<*>.toArray(ar: Array<E>): Array<E> = ar
|
||||
|
||||
@@ -20,6 +20,8 @@ fun A.forEach(s: String) {}
|
||||
package a
|
||||
|
||||
import b.*
|
||||
import checkType
|
||||
import _
|
||||
|
||||
class A {
|
||||
fun forEach() = this
|
||||
|
||||
@@ -20,6 +20,8 @@ fun A.forEach(s: String) {}
|
||||
package a
|
||||
|
||||
import b.*
|
||||
import checkType
|
||||
import _
|
||||
|
||||
class A {
|
||||
fun forEach() = this
|
||||
|
||||
@@ -625,6 +625,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
getTopLevelPackagesFromFileList(getKtFiles(testFiles, false))
|
||||
).toSet()
|
||||
|
||||
val checkTypeEnabled = testFiles.any { it.declareCheckType }
|
||||
val stepIntoFilter = Predicate<DeclarationDescriptor> { descriptor ->
|
||||
val module = DescriptorUtils.getContainingModuleOrNull(descriptor)
|
||||
if (module !in modules) return@Predicate false
|
||||
@@ -634,6 +635,8 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
return@Predicate fqName.isRoot || fqName.pathSegments().first() in packagesNames
|
||||
}
|
||||
|
||||
if (checkTypeEnabled && descriptor.name in NAMES_OF_CHECK_TYPE_HELPER) return@Predicate false
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
@@ -768,5 +771,7 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
||||
private val HASH_SANITIZER = fun(s: String): String = s.replace("@(\\d)+".toRegex(), "")
|
||||
|
||||
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
|
||||
get() = buildString {
|
||||
// Line separator is "\n" intentionally here (see DocumentImpl.assertValidSeparators)
|
||||
if (declareCheckType) {
|
||||
append(CHECK_TYPE_IMPORT + "\n")
|
||||
}
|
||||
if (declareFlexibleType) {
|
||||
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_PACKAGE = "tests._checkType"
|
||||
val CHECK_TYPE_IMPORT = "import $CHECK_TYPE_PACKAGE.*"
|
||||
|
||||
val EXPLICIT_FLEXIBLE_TYPES_DIRECTIVE = "EXPLICIT_FLEXIBLE_TYPES"
|
||||
val EXPLICIT_FLEXIBLE_PACKAGE = InternalFlexibleTypeTransformer.FLEXIBLE_TYPE_CLASSIFIER.packageFqName.asString()
|
||||
|
||||
Reference in New Issue
Block a user