FIR: Fix inference of builder-inference function from expect type
Previously, such calls were being completed with FULL mode and incorrect INFERENCE_NO_INFORMATION_FOR_PARAMETER has been reported
This commit is contained in:
committed by
TeamCityServer
parent
18e93b50d9
commit
592256976e
+17
@@ -0,0 +1,17 @@
|
||||
// WITH_RUNTIME
|
||||
// TARGET_BACKEND: JVM_IR
|
||||
|
||||
@OptIn(ExperimentalStdlibApi::class)
|
||||
fun getAllPossibleNames(subScopes: List<List<String>>): Set<String> = withValidityAssertion {
|
||||
buildSet {
|
||||
subScopes.flatMapTo(this) { it }
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <R> withValidityAssertion(action: () -> R): R {
|
||||
return action()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
return getAllPossibleNames(listOf(listOf("O"), listOf("K"))).joinToString("")
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
// ISSUE: KT-41164
|
||||
// WITH_RUNTIME
|
||||
// IGNORE_BACKEND_FIR: JVM_IR
|
||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||
|
||||
import kotlin.experimental.ExperimentalTypeInference
|
||||
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
// !LANGUAGE: +UnrestrictedBuilderInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: annotation.kt
|
||||
|
||||
package kotlin
|
||||
|
||||
annotation class BuilderInference
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
class Builder<T> {
|
||||
fun add(t: T) {}
|
||||
}
|
||||
|
||||
fun <S> build(@BuilderInference g: Builder<S>.() -> Unit): List<S> = TODO()
|
||||
fun <S> wrongBuild(g: Builder<S>.() -> Unit): List<S> = TODO()
|
||||
|
||||
fun <S> Builder<S>.extensionAdd(s: S) {}
|
||||
|
||||
@BuilderInference
|
||||
fun <S> Builder<S>.safeExtensionAdd(s: S) {}
|
||||
|
||||
val member = build {
|
||||
add(42)
|
||||
}
|
||||
|
||||
val memberWithoutAnn = wrongBuild {
|
||||
add(<!ARGUMENT_TYPE_MISMATCH!>42<!>)
|
||||
}
|
||||
|
||||
val extension = build {
|
||||
extensionAdd("foo")
|
||||
}
|
||||
|
||||
val safeExtension = build {
|
||||
safeExtensionAdd("foo")
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !LANGUAGE: +UnrestrictedBuilderInference
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
// FILE: annotation.kt
|
||||
|
||||
+3
-3
@@ -77,11 +77,11 @@ FILE fqName:<root> fileName:/kt47082.kt
|
||||
$receiver: VALUE_PARAMETER name:<this> type:<root>.Derived<R of <root>.foo>
|
||||
BLOCK_BODY
|
||||
TYPE_OP type=kotlin.Unit origin=IMPLICIT_COERCION_TO_UNIT typeOperand=kotlin.Unit
|
||||
CALL 'public final fun toChannel <E, C> (destination: C of <root>.toChannel): C of <root>.toChannel declared in <root>' type=<root>.Derived<R of <root>.foo> origin=null
|
||||
CALL 'public final fun toChannel <E, C> (destination: C of <root>.toChannel): C of <root>.toChannel declared in <root>' type=<root>.Derived<IrErrorType(null)> origin=null
|
||||
<E>: R of <root>.foo
|
||||
<C>: <root>.Derived<R of <root>.foo>
|
||||
<C>: <root>.Derived<IrErrorType(null)>
|
||||
$receiver: GET_VAR 'r: <root>.Receiver<R of <root>.foo> declared in <root>.foo' type=<root>.Receiver<R of <root>.foo> origin=null
|
||||
destination: GET_VAR '<this>: <root>.Derived<R of <root>.foo> declared in <root>.foo.<anonymous>' type=<root>.Derived<R of <root>.foo> origin=null
|
||||
destination: GET_VAR '<this>: <root>.Derived<R of <root>.foo> declared in <root>.foo.<anonymous>' type=<root>.Derived<IrErrorType(null)> origin=null
|
||||
FUN name:box visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun box (): kotlin.String declared in <root>'
|
||||
|
||||
Reference in New Issue
Block a user