[FIR-TEST] Move analysis tests to separate module
This commit is contained in:
compiler/fir/analysis-tests/testData/resolve/problems/complexLambdaWithTypeVariableAsExpectedType.kt
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
fun <T> id(x: T): T = x
|
||||
fun <K> select(x: K, y: K): K = TODO()
|
||||
|
||||
fun test() {
|
||||
select(id { it.inv() }, id<(Int) -> Unit> { })
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
FILE: complexLambdaWithTypeVariableAsExpectedType.kt
|
||||
public final fun <T> id(x: R|T|): R|T| {
|
||||
^id R|<local>/x|
|
||||
}
|
||||
public final fun <K> select(x: R|K|, y: R|K|): R|K| {
|
||||
^select R|kotlin/TODO|()
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/select|<R|(kotlin/Int) -> kotlin/Unit|>(R|/id|<R|(kotlin/Int) -> kotlin/Int|>(<L> = id@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Int| {
|
||||
^ R|<local>/it|.R|kotlin/Int.inv|()
|
||||
}
|
||||
), R|/id|<R|(kotlin/Int) -> kotlin/Unit|>(<L> = id@fun <anonymous>(it: R|kotlin/Int|): R|kotlin/Unit| {
|
||||
Unit
|
||||
}
|
||||
))
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
// Original problem was discovered in `backend.main/org/jetbrains/kotlin/codegen/inline/InlineCache.kt`
|
||||
|
||||
// FILE: SLRUMap.java
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface SLRUMap<V> {
|
||||
void takeV(@NotNull V value);
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun <V> SLRUMap<V>.getOrPut(value: V) {
|
||||
<!INAPPLICABLE_CANDIDATE!>takeV<!>(value)
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
FILE: main.kt
|
||||
public final fun <V> R|SLRUMap<V>|.getOrPut(value: R|V|): R|kotlin/Unit| {
|
||||
<Inapplicable(INAPPLICABLE): [/SLRUMap.takeV]>#(R|<local>/value|)
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass<T> {
|
||||
public JavaClass(T t) {}
|
||||
|
||||
public T foo() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
fun main() {
|
||||
// See https://github.com/JetBrains/kotlin/commit/437a26684d3529ee2cfdbe54e59d50f4a6f0a611#diff-ba68311bbe28b71196c36a6246000382L176
|
||||
// In simplifyLowerConstraint, we add constraint Nothing? <: T!, approximating it with Nothing? <: T
|
||||
// But before it we already had T <: String from the explicit types
|
||||
// That lead us to constraint contradiction: Nothing? !<: String
|
||||
// We need to discuss the commit above at some point
|
||||
<!INAPPLICABLE_CANDIDATE!>JavaClass<!><String>(null).<!UNRESOLVED_REFERENCE!>foo<!>().<!UNRESOLVED_REFERENCE!>length<!>
|
||||
}
|
||||
+4
@@ -0,0 +1,4 @@
|
||||
FILE: main.kt
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
<Inapplicable(INAPPLICABLE): [/JavaClass.JavaClass]>#<R|kotlin/String|>(Null(null)).<Unresolved name: foo>#().<Unresolved name: length>#
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* There is some complex rules for conversions from java method `get...` to property
|
||||
* (see `JavaSyntheticPropertiesScope`), but they are not supported in FIR
|
||||
* It's possible to support them in `JavaClassUseSiteMemberScope`
|
||||
* But problem is that we also have `FirSyntheticPropertiesScope` that creates
|
||||
* synthetic properties for everithig
|
||||
*
|
||||
* Because of that such code is also resolves incorrect:
|
||||
*
|
||||
* class A {
|
||||
* fun getX(): Int = 1
|
||||
* }
|
||||
*
|
||||
* fun test(a: A) {
|
||||
* a.x // resolves to `getX`
|
||||
* }
|
||||
*/
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public String getVMParameters() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public class B {
|
||||
public Integer getVmParameters() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public class C {
|
||||
public String getVMParameters() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer getVmParameters() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: D.java
|
||||
|
||||
public class D {
|
||||
public boolean isGood() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test_1(x: A) {
|
||||
val str1 = x.vmParameters // OK
|
||||
val str2 = x.<!UNRESOLVED_REFERENCE!>vMParameters<!> // should be error
|
||||
}
|
||||
|
||||
fun test_2(x: B) {
|
||||
val int = x.vmParameters // OK
|
||||
val error = x.<!UNRESOLVED_REFERENCE!>vMParameters<!> // should be error
|
||||
}
|
||||
|
||||
fun test_3(x: C) {
|
||||
val error = x.<!AMBIGUITY!>vmParameters<!> // should be error
|
||||
val int = x.<!UNRESOLVED_REFERENCE!>vMParameters<!> // should be error
|
||||
}
|
||||
|
||||
class Foo {
|
||||
fun getX(): Int = 1
|
||||
}
|
||||
|
||||
fun test_4(foo: Foo) {
|
||||
foo.x // should be error
|
||||
}
|
||||
|
||||
fun test_5(x: D) {
|
||||
x.isGood
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
FILE: main.kt
|
||||
public final fun test_1(x: R|A|): R|kotlin/Unit| {
|
||||
lval str1: R|ft<kotlin/String, kotlin/String?>!| = R|<local>/x|.R|/A.vmParameters|
|
||||
lval str2: <ERROR TYPE REF: Unresolved name: vMParameters> = R|<local>/x|.<Unresolved name: vMParameters>#
|
||||
}
|
||||
public final fun test_2(x: R|B|): R|kotlin/Unit| {
|
||||
lval int: R|ft<kotlin/Int, kotlin/Int?>!| = R|<local>/x|.R|/B.vmParameters|
|
||||
lval error: <ERROR TYPE REF: Unresolved name: vMParameters> = R|<local>/x|.<Unresolved name: vMParameters>#
|
||||
}
|
||||
public final fun test_3(x: R|C|): R|kotlin/Unit| {
|
||||
lval error: <ERROR TYPE REF: Ambiguity: vmParameters, [/C.vmParameters, /C.vmParameters]> = R|<local>/x|.<Ambiguity: vmParameters, [/C.vmParameters, /C.vmParameters]>#
|
||||
lval int: <ERROR TYPE REF: Unresolved name: vMParameters> = R|<local>/x|.<Unresolved name: vMParameters>#
|
||||
}
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun getX(): R|kotlin/Int| {
|
||||
^getX Int(1)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test_4(foo: R|Foo|): R|kotlin/Unit| {
|
||||
R|<local>/foo|.R|/Foo.x|
|
||||
}
|
||||
public final fun test_5(x: R|D|): R|kotlin/Unit| {
|
||||
R|<local>/x|.R|/D.isGood|
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
// FILE: Inv.java
|
||||
|
||||
public class Inv<T> {}
|
||||
|
||||
// FILE: A.java
|
||||
|
||||
public class A {
|
||||
public static Inv<String[]> KEY = new Inv<>();
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
fun test() {
|
||||
val key = A.KEY
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
FILE: main.kt
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
lval key: R|ft<Inv<<error>>, Inv<<error>>?>!| = Q|A|.R|/A.KEY|
|
||||
}
|
||||
Reference in New Issue
Block a user