[FIR] Add tests for KT-37070 , KT-37066
This commit is contained in:
committed by
Mikhail Glukhikh
parent
97007ae6c5
commit
9a352ad7b0
@@ -0,0 +1,40 @@
|
||||
// !CHECK_TYPE
|
||||
// ISSUE: KT-37070
|
||||
|
||||
class KotlinClass(private val name: String) : Comparable<KotlinClass> {
|
||||
override operator fun compareTo(that: KotlinClass): Int {
|
||||
return name.compareTo(that.name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
fun case1(kotlinClass: KotlinClass?) {
|
||||
|
||||
val value = kotlinClass?.let {
|
||||
it
|
||||
}
|
||||
|
||||
value.checkType { _<KotlinClass?>() }
|
||||
|
||||
val lambda = kotlinClass?.let {
|
||||
{<!UNRESOLVED_REFERENCE!>it<!>}
|
||||
}
|
||||
|
||||
lambda.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Unit, KotlinClass?>>() }
|
||||
}
|
||||
// TESTCASE NUMBER: 2
|
||||
fun case2(kotlinClass: KotlinClass) {
|
||||
|
||||
val value = kotlinClass.let {
|
||||
it
|
||||
}
|
||||
|
||||
value.checkType { _<KotlinClass>() }
|
||||
|
||||
val lambda = kotlinClass.let {
|
||||
{<!UNRESOLVED_REFERENCE!>it<!>}
|
||||
}
|
||||
|
||||
lambda.checkType { <!INAPPLICABLE_CANDIDATE!>_<!><Function1<Unit, KotlinClass?>>() }
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
FILE: lambdaArgInScopeFunction.kt
|
||||
public final class KotlinClass : R|kotlin/Comparable<KotlinClass>| {
|
||||
public constructor(name: R|kotlin/String|): R|KotlinClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final val name: R|kotlin/String| = R|<local>/name|
|
||||
private get(): R|kotlin/String|
|
||||
|
||||
public final override operator fun compareTo(that: R|KotlinClass|): R|kotlin/Int| {
|
||||
^compareTo this@R|/KotlinClass|.R|/KotlinClass.name|.R|kotlin/String.compareTo|(R|<local>/that|.R|/KotlinClass.name|)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun case1(kotlinClass: R|KotlinClass?|): R|kotlin/Unit| {
|
||||
lval value: R|KotlinClass?| = R|<local>/kotlinClass|?.R|kotlin/let|<R|KotlinClass|, R|KotlinClass|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|KotlinClass| <kind=EXACTLY_ONCE> {
|
||||
^ 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?|>()
|
||||
}
|
||||
)
|
||||
lval lambda: R|kotlin/Nothing?| = R|<local>/kotlinClass|?.R|kotlin/let|<R|KotlinClass|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|kotlin/Nothing| <kind=EXACTLY_ONCE> {
|
||||
^ let@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: it> {
|
||||
^ <Unresolved name: it>#
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|<local>/lambda|.R|tests/_checkType/checkType|<R|kotlin/Nothing?|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Nothing?>|.<anonymous>(): R|kotlin/Unit| {
|
||||
^ <Inapplicable(WRONG_RECEIVER): [tests/_checkType/_]>#<R|(kotlin/Unit) -> KotlinClass?|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
public final fun case2(kotlinClass: R|KotlinClass|): R|kotlin/Unit| {
|
||||
lval value: R|KotlinClass| = R|<local>/kotlinClass|.R|kotlin/let|<R|KotlinClass|, R|KotlinClass|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|KotlinClass| <kind=EXACTLY_ONCE> {
|
||||
^ 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|>()
|
||||
}
|
||||
)
|
||||
lval lambda: R|kotlin/Nothing| = R|<local>/kotlinClass|.R|kotlin/let|<R|KotlinClass|, R|kotlin/Nothing|>(<L> = let@fun <anonymous>(it: R|KotlinClass|): R|kotlin/Nothing| <kind=EXACTLY_ONCE> {
|
||||
^ let@fun <anonymous>(): <ERROR TYPE REF: Unresolved name: it> {
|
||||
^ <Unresolved name: it>#
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
R|<local>/lambda|.R|tests/_checkType/checkType|<R|kotlin/Nothing|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Nothing>|.<anonymous>(): R|kotlin/Unit| {
|
||||
^ <Inapplicable(WRONG_RECEIVER): [tests/_checkType/_]>#<R|(kotlin/Unit) -> KotlinClass?|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
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>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| {
|
||||
}
|
||||
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
// !CHECK_TYPE
|
||||
// UNEXPECTED BEHAVIOUR
|
||||
// ISSUES: KT-37066
|
||||
|
||||
// TESTCASE NUMBER: 1
|
||||
// FILE: JavaClass.java
|
||||
public final class JavaClass implements Comparable<JavaClass> {
|
||||
private final String name;
|
||||
|
||||
public JavaClass (String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(JavaClass that) {
|
||||
return this.name.compareTo(that.name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// FILE: KotlinClass.kt
|
||||
fun case1(javaClass: JavaClass?) {
|
||||
val validType: (JavaClass) -> Boolean = if (javaClass != null) { it -> it == javaClass } else BooCase1.FILTER
|
||||
|
||||
val invalidType = if (javaClass != null) { it -> it == javaClass } else BooCase1.FILTER
|
||||
|
||||
validType.checkType { _<Function1<JavaClass, Boolean>>() } //ok
|
||||
|
||||
invalidType.checkType { _<Function1<Nothing, Boolean>>() } //(!!!)
|
||||
|
||||
Case1(javaClass).x.checkType { _<Function1<Nothing, Boolean>>() } //(!!!)
|
||||
}
|
||||
|
||||
class Case1(val javaClass: JavaClass?) {
|
||||
val x = if (javaClass != null) { it -> it == javaClass } else BooCase2.FILTER
|
||||
}
|
||||
|
||||
class BooCase1() {
|
||||
companion object {
|
||||
val FILTER: (JavaClass) -> Boolean = { true }
|
||||
}
|
||||
}
|
||||
|
||||
// TESTCASE NUMBER: 2
|
||||
|
||||
class KotlinClass(private val name: String) : Comparable<KotlinClass> {
|
||||
override operator fun compareTo(that: KotlinClass): Int {
|
||||
return name.compareTo(that.name)
|
||||
}
|
||||
}
|
||||
|
||||
fun case2(kotlinClass: KotlinClass?) {
|
||||
val validType: (KotlinClass) -> Boolean = if (kotlinClass != null) { it -> it == kotlinClass } else BooCase2.FILTER
|
||||
val invalidType = if (kotlinClass != null) { it -> it == kotlinClass } else BooCase2.FILTER
|
||||
|
||||
validType.checkType { _<Function1<KotlinClass, Boolean>>() } //ok
|
||||
|
||||
invalidType.checkType { _<Function1<Nothing, Boolean>>() } //(!!!)
|
||||
|
||||
Case2(kotlinClass).x.checkType { _<Function1<Nothing, Boolean>>() } //(!!!)
|
||||
}
|
||||
|
||||
class Case2(val kotlinClass: KotlinClass?) {
|
||||
val x = if (kotlinClass != null) { it -> it == kotlinClass } else BooCase2.FILTER
|
||||
}
|
||||
|
||||
class BooCase2() {
|
||||
companion object {
|
||||
val FILTER: (KotlinClass) -> Boolean = { true }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
FILE: KotlinClass.kt
|
||||
public final fun case1(javaClass: R|JavaClass?|): R|kotlin/Unit| {
|
||||
lval validType: R|(JavaClass) -> kotlin/Boolean| = when () {
|
||||
!=(R|<local>/javaClass|, Null(null)) -> {
|
||||
fun <anonymous>(it: R|kotlin/Nothing|): R|kotlin/Boolean| {
|
||||
^ ==(R|<local>/it|, R|<local>/javaClass|)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Q|BooCase1|.R|/BooCase1.Companion.FILTER|
|
||||
}
|
||||
}
|
||||
|
||||
lval invalidType: R|(kotlin/Nothing) -> kotlin/Boolean| = when () {
|
||||
!=(R|<local>/javaClass|, Null(null)) -> {
|
||||
fun <anonymous>(it: R|kotlin/Nothing|): R|kotlin/Boolean| {
|
||||
^ ==(R|<local>/it|, R|<local>/javaClass|)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Q|BooCase1|.R|/BooCase1.Companion.FILTER|
|
||||
}
|
||||
}
|
||||
|
||||
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>/invalidType|.R|tests/_checkType/checkType|<R|(kotlin/Nothing) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<kotlin/Nothing, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
}
|
||||
)
|
||||
R|/Case1.Case1|(R|<local>/javaClass|).R|/Case1.x|.R|tests/_checkType/checkType|<R|(kotlin/Nothing) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<kotlin/Nothing, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
public final class Case1 : R|kotlin/Any| {
|
||||
public constructor(javaClass: R|JavaClass?|): R|Case1| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val javaClass: R|JavaClass?| = R|<local>/javaClass|
|
||||
public get(): R|JavaClass?|
|
||||
|
||||
public final val x: R|(kotlin/Nothing) -> kotlin/Boolean| = when () {
|
||||
!=(R|<local>/javaClass|, Null(null)) -> {
|
||||
fun <anonymous>(it: R|kotlin/Nothing|): R|kotlin/Boolean| {
|
||||
^ ==(R|<local>/it|, R|<local>/javaClass|)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Q|BooCase2|.R|/BooCase2.Companion.FILTER|
|
||||
}
|
||||
}
|
||||
|
||||
public get(): R|(kotlin/Nothing) -> kotlin/Boolean|
|
||||
|
||||
}
|
||||
public final class BooCase1 : R|kotlin/Any| {
|
||||
public constructor(): R|BooCase1| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|BooCase1.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val FILTER: R|(JavaClass) -> kotlin/Boolean| = fun <anonymous>(it: R|JavaClass|): R|kotlin/Boolean| {
|
||||
^ Boolean(true)
|
||||
}
|
||||
|
||||
public get(): R|(JavaClass) -> kotlin/Boolean|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public final class KotlinClass : R|kotlin/Comparable<KotlinClass>| {
|
||||
public constructor(name: R|kotlin/String|): R|KotlinClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
private final val name: R|kotlin/String| = R|<local>/name|
|
||||
private get(): R|kotlin/String|
|
||||
|
||||
public final override operator fun compareTo(that: R|KotlinClass|): R|kotlin/Int| {
|
||||
^compareTo this@R|/KotlinClass|.R|/KotlinClass.name|.R|kotlin/String.compareTo|(R|<local>/that|.R|/KotlinClass.name|)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun case2(kotlinClass: R|KotlinClass?|): R|kotlin/Unit| {
|
||||
lval validType: R|(KotlinClass) -> kotlin/Boolean| = when () {
|
||||
!=(R|<local>/kotlinClass|, Null(null)) -> {
|
||||
fun <anonymous>(it: R|kotlin/Nothing|): R|kotlin/Boolean| {
|
||||
^ ==(R|<local>/it|, R|<local>/kotlinClass|)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Q|BooCase2|.R|/BooCase2.Companion.FILTER|
|
||||
}
|
||||
}
|
||||
|
||||
lval invalidType: R|(kotlin/Nothing) -> kotlin/Boolean| = when () {
|
||||
!=(R|<local>/kotlinClass|, Null(null)) -> {
|
||||
fun <anonymous>(it: R|kotlin/Nothing|): R|kotlin/Boolean| {
|
||||
^ ==(R|<local>/it|, R|<local>/kotlinClass|)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Q|BooCase2|.R|/BooCase2.Companion.FILTER|
|
||||
}
|
||||
}
|
||||
|
||||
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>/invalidType|.R|tests/_checkType/checkType|<R|(kotlin/Nothing) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<kotlin/Nothing, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
}
|
||||
)
|
||||
R|/Case2.Case2|(R|<local>/kotlinClass|).R|/Case2.x|.R|tests/_checkType/checkType|<R|(kotlin/Nothing) -> kotlin/Boolean|>(<L> = checkType@fun R|tests/_checkType/Inv<kotlin/Function1<kotlin/Nothing, kotlin/Boolean>>|.<anonymous>(): R|kotlin/Unit| {
|
||||
this@R|special/anonymous|.R|tests/_checkType/_|<R|(kotlin/Nothing) -> kotlin/Boolean|>()
|
||||
}
|
||||
)
|
||||
}
|
||||
public final class Case2 : R|kotlin/Any| {
|
||||
public constructor(kotlinClass: R|KotlinClass?|): R|Case2| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val kotlinClass: R|KotlinClass?| = R|<local>/kotlinClass|
|
||||
public get(): R|KotlinClass?|
|
||||
|
||||
public final val x: R|(kotlin/Nothing) -> kotlin/Boolean| = when () {
|
||||
!=(R|<local>/kotlinClass|, Null(null)) -> {
|
||||
fun <anonymous>(it: R|kotlin/Nothing|): R|kotlin/Boolean| {
|
||||
^ ==(R|<local>/it|, R|<local>/kotlinClass|)
|
||||
}
|
||||
|
||||
}
|
||||
else -> {
|
||||
Q|BooCase2|.R|/BooCase2.Companion.FILTER|
|
||||
}
|
||||
}
|
||||
|
||||
public get(): R|(kotlin/Nothing) -> kotlin/Boolean|
|
||||
|
||||
}
|
||||
public final class BooCase2 : R|kotlin/Any| {
|
||||
public constructor(): R|BooCase2| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final companion object Companion : R|kotlin/Any| {
|
||||
private constructor(): R|BooCase2.Companion| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val FILTER: R|(KotlinClass) -> kotlin/Boolean| = fun <anonymous>(it: R|KotlinClass|): R|kotlin/Boolean| {
|
||||
^ Boolean(true)
|
||||
}
|
||||
|
||||
public get(): R|(KotlinClass) -> kotlin/Boolean|
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
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>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
public final fun <E> R|tests/_checkType/Inv<E>|._(): R|kotlin/Unit| {
|
||||
}
|
||||
public final infix fun <T> R|T|.checkType(f: R|tests/_checkType/Inv<T>.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
+10
@@ -218,6 +218,16 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/javaStaticScopeInheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaArgInScopeFunction.kt")
|
||||
public void testLambdaArgInScopeFunction() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/lambdaArgInScopeFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaPropertyTypeInference.kt")
|
||||
public void testLambdaPropertyTypeInference() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/lambdaPropertyTypeInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionsHiding.kt")
|
||||
public void testLocalFunctionsHiding() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/localFunctionsHiding.kt");
|
||||
|
||||
Generated
+10
@@ -218,6 +218,16 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/resolve/testData/resolve/javaStaticScopeInheritance.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaArgInScopeFunction.kt")
|
||||
public void testLambdaArgInScopeFunction() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/lambdaArgInScopeFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaPropertyTypeInference.kt")
|
||||
public void testLambdaPropertyTypeInference() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/lambdaPropertyTypeInference.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("localFunctionsHiding.kt")
|
||||
public void testLocalFunctionsHiding() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/localFunctionsHiding.kt");
|
||||
|
||||
Reference in New Issue
Block a user