[FIR] DFA fix after x?.syntheticProperty ?: return

This commit is contained in:
Mikhail Glukhikh
2020-02-05 17:23:51 +03:00
parent d23c03e9dc
commit 1bbcec4935
3 changed files with 36 additions and 4 deletions
@@ -12,9 +12,9 @@ import org.jetbrains.kotlin.fir.contracts.description.ConeConstantReference
import org.jetbrains.kotlin.fir.expressions.*
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
import org.jetbrains.kotlin.fir.references.FirThisReference
import org.jetbrains.kotlin.fir.references.impl.FirExplicitThisReference
import org.jetbrains.kotlin.fir.resolve.calls.FirNamedReferenceWithCandidate
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirAccessorSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
import org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import org.jetbrains.kotlin.fir.types.ConeKotlinType
@@ -109,7 +109,7 @@ internal val FirElement.symbol: AbstractFirBasedSymbol<*>?
is FirSymbolOwner<*> -> symbol
is FirWhenSubjectExpression -> whenSubject.whenExpression.subject?.symbol
else -> null
}?.takeIf { this is FirThisReceiverExpression || it !is FirFunctionSymbol<*> }
}?.takeIf { this is FirThisReceiverExpression || (it !is FirFunctionSymbol<*> && it !is FirAccessorSymbol) }
@DfaInternals
internal val FirResolvable.symbol: AbstractFirBasedSymbol<*>?
@@ -45,7 +45,7 @@ fun test5(x: AnotherClass?) {
fun test6(x: SomeClass?) {
val bar = x?.bar as? String ?: return
x.<!INAPPLICABLE_CANDIDATE!>foo<!>
x.foo
}
fun test7(x: AnotherClass?) {
@@ -53,5 +53,13 @@ fun test7(x: AnotherClass?) {
x.foo
}
fun test8(x: AnotherClass?) {
val bar = x?.bar ?: return
x.foo
}
fun test9(x: AnotherClass?) {
val baz = x?.baz() ?: return
x.foo
}
@@ -79,7 +79,7 @@ FILE: test.kt
}
}
R|<local>/x|.<Inapplicable(WRONG_RECEIVER): [/SomeClass.foo]>#
R|<local>/x|.R|/SomeClass.foo|
}
public final fun test7(x: R|AnotherClass?|): R|kotlin/Unit| {
lval baz: R|kotlin/Boolean| = when (lval <elvis>: R|kotlin/Boolean?| = (R|<local>/x|?.R|/AnotherClass.baz|() as? R|kotlin/Boolean|)) {
@@ -93,3 +93,27 @@ FILE: test.kt
R|<local>/x|.R|/AnotherClass.foo|
}
public final fun test8(x: R|AnotherClass?|): R|kotlin/Unit| {
lval bar: R|kotlin/CharSequence| = when (lval <elvis>: R|kotlin/CharSequence?| = R|<local>/x|?.R|/AnotherClass.bar|) {
==($subj$, Null(null)) -> {
^test8 Unit
}
else -> {
R|<local>/<elvis>|
}
}
R|<local>/x|.R|/AnotherClass.foo|
}
public final fun test9(x: R|AnotherClass?|): R|kotlin/Unit| {
lval baz: R|kotlin/Any| = when (lval <elvis>: R|kotlin/Any?| = R|<local>/x|?.R|/AnotherClass.baz|()) {
==($subj$, Null(null)) -> {
^test9 Unit
}
else -> {
R|<local>/<elvis>|
}
}
R|<local>/x|.R|/AnotherClass.foo|
}