FirCallResolve: disable property resolve optimization in builder inference

#KT-57889 Fixed
This commit is contained in:
Mikhail Glukhikh
2023-04-17 19:38:02 +02:00
committed by Space Team
parent f9a7a7fda2
commit 9374202ebc
7 changed files with 58 additions and 23 deletions
@@ -1,10 +0,0 @@
// ISSUE: KT-57889
class SafeResult<S>
inline fun <T> checkNotEdt(body: (SafeResult<T>) -> Nothing) {}
private fun <V> getNonEdt(): SafeResult<V> {
<!NEW_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>checkNotEdt<!> { return it }
return SafeResult()
}
@@ -1,3 +1,4 @@
// FIR_IDENTICAL
// ISSUE: KT-57889
class SafeResult<S>
@@ -9,16 +9,16 @@ fun main(arg: Any) {
val x = 57
val value = myBuilder {
doSmthng("one ")
run { a; this }.a = <!ASSIGNMENT_TYPE_MISMATCH!>10<!>
run { a; this }.a = 10
a += 1
this.a = <!ASSIGNMENT_TYPE_MISMATCH!>57<!>
this.a = 57
this.<!ILLEGAL_SELECTOR, VARIABLE_EXPECTED!>(a)<!> = 57
a = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
(a) = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
a = x
(a) = x
a.<!FUNCTION_CALL_EXPECTED, VARIABLE_EXPECTED!>hashCode<!> = 99
if (arg is String) {
a = arg
}
}
println(value.a?.count { it in 'l' .. 'q' })
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value.a?.<!UNRESOLVED_REFERENCE!>count<!> { <!UNRESOLVED_REFERENCE!>it<!> in 'l' .. 'q' })
}
@@ -1,4 +1,5 @@
// !LANGUAGE: +NoBuilderInferenceWithoutAnnotationRestriction
// FIR_DUMP
class Foo<T : Any> {
fun doSmthng(arg: T) {}
@@ -11,11 +12,11 @@ fun main(arg: Any) {
val x = 57
val value = myBuilder {
doSmthng("one ")
a = <!ASSIGNMENT_TYPE_MISMATCH!>57<!>
a = <!ASSIGNMENT_TYPE_MISMATCH!>x<!>
a = 57
a = x
if (arg is String) {
a = arg
}
}
println(value.a?.count { it in 'l' .. 'q' })
<!OVERLOAD_RESOLUTION_AMBIGUITY!>println<!>(value.a?.<!UNRESOLVED_REFERENCE!>count<!> { <!UNRESOLVED_REFERENCE!>it<!> in 'l' .. 'q' })
}
@@ -0,0 +1,36 @@
FILE: unsafeAssignment_noReport.fir.kt
public final class Foo<T : R|kotlin/Any|> : R|kotlin/Any| {
public constructor<T : R|kotlin/Any|>(): R|Foo<T>| {
super<R|kotlin/Any|>()
}
public final fun doSmthng(arg: R|T|): R|kotlin/Unit| {
}
public final var a: R|T?| = Null(null)
public get(): R|T?|
public set(value: R|T?|): R|kotlin/Unit|
}
public final fun <T : R|kotlin/Any|> myBuilder(block: R|Foo<T>.() -> kotlin/Unit|): R|Foo<T>| {
^myBuilder R|/Foo.Foo|<R|T|>().R|kotlin/apply|<R|Foo<T>|>(R|<local>/block|)
}
public final fun main(arg: R|kotlin/Any|): R|kotlin/Unit| {
lval x: R|kotlin/Int| = Int(57)
lval value: R|Foo<kotlin/Any>| = R|/myBuilder|<R|kotlin/Any|>(<L> = myBuilder@fun R|Foo<kotlin/Any>|.<anonymous>(): R|kotlin/Unit| <inline=NoInline> {
this@R|special/anonymous|.R|SubstitutionOverride</Foo.doSmthng: R|kotlin/Unit|>|(String(one ))
this@R|special/anonymous|.R|SubstitutionOverride</Foo.a: R|Stub (chain inference): TypeVariable(T)?|>| = Int(57)
this@R|special/anonymous|.R|SubstitutionOverride</Foo.a: R|Stub (chain inference): TypeVariable(T)?|>| = R|<local>/x|
when () {
(R|<local>/arg| is R|kotlin/String|) -> {
this@R|special/anonymous|.R|SubstitutionOverride</Foo.a: R|Stub (chain inference): TypeVariable(T)?|>| = R|<local>/arg|
}
}
}
)
<Ambiguity: println, [kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println, kotlin/io/println]>#(R|<local>/value|.R|SubstitutionOverride</Foo.a: R|kotlin/Any?|>|?.{ $subj$.<Unresolved name: count>#(<L> = count@fun <anonymous>(): R|kotlin/Boolean| <inline=Unknown> {
^ Char(l).R|kotlin/Char.rangeTo|(Char(q)).R|kotlin/ranges/CharRange.contains|(<Unresolved name: it>#)
}
) })
}
@@ -1,4 +1,5 @@
// !LANGUAGE: +NoBuilderInferenceWithoutAnnotationRestriction
// FIR_DUMP
class Foo<T : Any> {
fun doSmthng(arg: T) {}