FIR: support don't use builder inference if possible
In this commit we upgrade FIR builder inference logic from the compiler version to 1.7. FIR-based compiler now works with "don't use builder inference" flag always ON and supports switching the flag "use builder inference only if needed". To do it, ContraintSystemCompleter (FIR) and KotlinConstraintSystemCompleter (FE 1.0) are made similar with extracting some common parts into ConstraintSystemCompletionContext. Test status: one BB test fails after this commit (KT-49285). Also we have a crush in DFA logic in FIR bootstrap test and somehow questionable behavior in FIR diagnostic test. However, two BB tests were fixed, the 3rd case from KT-49925 were also fixed. #KT-49925 Fixed
This commit is contained in:
committed by
teamcity
parent
d2bfb7153e
commit
e8be9d4861
+3
-3
@@ -20,10 +20,10 @@ fun <K> id(x: K): K = x
|
||||
fun main() {
|
||||
val x: Map<in String, String> = buildMap {
|
||||
put("", "")
|
||||
swap(foo())
|
||||
swap(<!ARGUMENT_TYPE_MISMATCH!>foo()<!>)
|
||||
} // `Map<CharSequence, String>` if we use builder inference, `Map<String, String>` if we don't
|
||||
|
||||
val y: MutableMap<String, CharSequence> = build7 {
|
||||
<!ARGUMENT_TYPE_MISMATCH!>id(run { this })<!>
|
||||
<!ARGUMENT_TYPE_MISMATCH, TYPE_MISMATCH, TYPE_MISMATCH!>id(run { this })<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -204,7 +204,7 @@ interface Foo2<K, V> {
|
||||
fun <L, K, V> twoBuilderLambdas(@BuilderInference block: Foo<L>.() -> Unit, @BuilderInference block2: Foo2<K, V>.() -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>twoBuilderLambdas<!>(
|
||||
twoBuilderLambdas(
|
||||
{
|
||||
add("")
|
||||
with (get()) {
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -OPT_IN_IS_NOT_ENABLED -UNUSED_VARIABLE
|
||||
// WITH_STDLIB
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
@OptIn(ExperimentalTypeInference::class)
|
||||
fun <R> combined(
|
||||
check: () -> Unit,
|
||||
@BuilderInference block: TestInterface<R>.() -> Unit
|
||||
): R = TODO()
|
||||
|
||||
interface TestInterface<R> {
|
||||
fun emit(r: R)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val ret = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>combined<!>({ }) {
|
||||
emit(1)
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -DEPRECATION -OPT_IN_IS_NOT_ENABLED -UNUSED_VARIABLE
|
||||
// WITH_STDLIB
|
||||
|
||||
|
||||
+2
-2
@@ -5,8 +5,8 @@
|
||||
fun <K, V> buildMap(builderAction: MutableMap<K, V>.() -> Unit): Map<K, V> = mapOf()
|
||||
|
||||
fun box(): String {
|
||||
val x = <!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>buildMap<!> {
|
||||
val x = buildMap {
|
||||
put("", "")
|
||||
}
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ fun test2() {
|
||||
fun <T, R> baz(body: (List<R>) -> T): T = fail()
|
||||
|
||||
fun test3() {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>baz<!> {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>baz<!> {
|
||||
true
|
||||
}
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>baz<!> { x ->
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>baz<!> { x ->
|
||||
true
|
||||
}
|
||||
}
|
||||
@@ -37,10 +37,10 @@ fun test3() {
|
||||
fun <T, R : Any> brr(body: (List<R?>) -> T): T = fail()
|
||||
|
||||
fun test4() {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>brr<!> {
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>brr<!> {
|
||||
true
|
||||
}
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER, NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>brr<!> { x ->
|
||||
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>brr<!> { x ->
|
||||
true
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user