[FIR] Implement new completion mode calculator

Note that `testDelegates` now fails due to KT-37638 and
    `testSimpleIn` fails due to problems with type parameters
    of inner classes
This commit is contained in:
Dmitriy Novozhilov
2020-03-20 15:20:09 +03:00
parent ea02855ba6
commit 5f9f01fe4e
14 changed files with 340 additions and 111 deletions
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_FIR: JVM_IR
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
-1
View File
@@ -1,7 +1,6 @@
// !LANGUAGE: +NewInference
// WITH_RUNTIME
// KJS_WITH_FULL_RUNTIME
// IGNORE_BACKEND_FIR: JVM_IR
class Holder(val list: List<String>?)
@@ -0,0 +1,2 @@
Failures detected in FirBodyResolveTransformerAdapter, file: /simpleIn.fir.kt
Cause: java.lang.RuntimeException: While resolving call R|<local>/outer|.set#(R?C|/infer|<R|kotlin/Any|>(String()))
@@ -1,30 +0,0 @@
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
interface I {
fun foo()
}
data class Pair<X, Y>(val fst: X, val snd: Y)
class A(f: Pair<Int, (I) -> Unit>? = null)
class B(f: ((I) -> Unit)? = null)
fun main() {
val cond = true
A(
if (cond) {
Pair(1, { baz -> baz.<!UNRESOLVED_REFERENCE!>foo<!>() })
} else {
null
}
)
<!INAPPLICABLE_CANDIDATE!>B<!>(
if (cond) {
{ baz -> baz.<!UNRESOLVED_REFERENCE!>foo<!>() }
} else {
null
}
)
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// !LANGUAGE: +NewInference
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
@@ -0,0 +1,17 @@
Failures detected in FirImplicitTypeBodyResolveTransformerAdapter, file: /My.kt
Cause: java.lang.RuntimeException: While resolving call Q|Properties|.R?C|/Properties.calcVal|(<L> = calcVal@fun <implicit>.<anonymous>(): <implicit> {
lval y: <implicit> = x#.plus#(IntegerLiteral(1))
when () {
CMP(>, y#.compareTo#(IntegerLiteral(0))) -> {
MyBase#.derivedWrapper#()
}
CMP(<, x#.compareTo#(IntegerLiteral(0))) -> {
MyBase#.exoticWrapper#(x#)
}
else -> {
throw java#.lang#.NullPointerException#(String())
}
}
}
)
@@ -0,0 +1,76 @@
// !WITH_NEW_INFERENCE
// NI_EXPECTED_FILE
// JAVAC_EXPECTED_FILE
// FILE: Base.java
public interface Base {}
// FILE: Other.java
public interface Other {}
// FILE: Derived.java
public final class Derived<T> implements Base, Other {}
// FILE: Exotic.java
public final class Exotic implements Base, Other {
int x;
Exotic(int x) {
this.x = x;
}
}
// FILE: Properties.java
import kotlin.jvm.functions.Function0;
class Val<T> {
Function0<T> initializer;
Val(Function0<T> initializer) {
this.initializer = initializer;
}
T getValue(Object instance, Object metadata) {
return initializer.invoke();
}
}
class Properties {
static <T> Val<T> calcVal(Function0<T> initializer) {
return new Val<T>(initializer);
}
}
// FILE: My.kt
open class Wrapper<out T: Base>(val v: T)
class DerivedWrapper(v: Derived<*>): Wrapper<Derived<*>>(v)
class ExoticWrapper(v: Exotic): Wrapper<Exotic>(v)
object MyBase {
fun derived() = Derived<String>()
fun exotic(x: Int) = Exotic(x)
fun derivedWrapper() = DerivedWrapper(derived())
fun exoticWrapper(x: Int) = ExoticWrapper(exotic(x))
}
class My(val x: Int) {
val wrapper/*: Wrapper<*>*/ by Properties.calcVal {
val y = x + 1
when {
y > 0 -> MyBase.derivedWrapper()
x < 0 -> MyBase.exoticWrapper(x)
else -> throw java.lang.NullPointerException("")
}
}
}
@@ -1,4 +1,3 @@
// FIR_IDENTICAL
// !WITH_NEW_INFERENCE
// NI_EXPECTED_FILE
// JAVAC_EXPECTED_FILE
@@ -3,7 +3,7 @@ FILE fqName:<root> fileName:/whenUnusedExpression.kt
VALUE_PARAMETER name:b index:0 type:kotlin.Boolean
VALUE_PARAMETER name:i index:1 type:kotlin.Int
BLOCK_BODY
WHEN type=kotlin.Int? origin=IF
WHEN type=kotlin.Int origin=IF
BRANCH
if: GET_VAR 'b: kotlin.Boolean declared in <root>.test' type=kotlin.Boolean origin=null
then: BLOCK type=kotlin.Int origin=WHEN