[FIR] Preserve information about prefix/postfix-ness
This information is needed for dynamics
This commit is contained in:
+2
@@ -113,6 +113,8 @@ internal open class FirElementsRecorder : FirVisitor<Unit, MutableMap<KtElement,
|
||||
// For secondary constructors without explicit delegated constructor call, the PSI tree always create an empty
|
||||
// KtConstructorDelegationCall. In this case, the source in FIR has this fake source kind.
|
||||
it.kind == KtFakeSourceElementKind.ImplicitConstructor ||
|
||||
it.kind == KtFakeSourceElementKind.DesugaredPrefixNameReference ||
|
||||
it.kind == KtFakeSourceElementKind.DesugaredPostfixNameReference ||
|
||||
it.isSourceForCompoundAccess(element)
|
||||
}.psi as? KtElement
|
||||
?: return
|
||||
|
||||
+6
-1
@@ -616,7 +616,12 @@ abstract class BaseFirBuilder<T>(val baseSession: FirSession, val context: Conte
|
||||
val resultInitializer = buildFunctionCall {
|
||||
source = desugaredSource
|
||||
calleeReference = buildSimpleNamedReference {
|
||||
source = operationReference?.toFirSourceElement()
|
||||
val kind = if (prefix) {
|
||||
KtFakeSourceElementKind.DesugaredPrefixNameReference
|
||||
} else {
|
||||
KtFakeSourceElementKind.DesugaredPostfixNameReference
|
||||
}
|
||||
source = operationReference?.toFirSourceElement(kind)
|
||||
name = callName
|
||||
}
|
||||
explicitReceiver = if (prefix) {
|
||||
|
||||
@@ -110,6 +110,12 @@ sealed class KtFakeSourceElementKind : KtSourceElementKind() {
|
||||
// x = x++ -> x = { val <unary> = x; x = <unary>.inc(); <unary> }
|
||||
object DesugaredIncrementOrDecrement : KtFakeSourceElementKind()
|
||||
|
||||
// ++x --> `inc` calleeReference
|
||||
object DesugaredPrefixNameReference : KtFakeSourceElementKind()
|
||||
|
||||
// x++ --> `inc` calleeReference
|
||||
object DesugaredPostfixNameReference : KtFakeSourceElementKind()
|
||||
|
||||
// x !in list --> !(x in list) where ! and !(x in list) will have a fake source
|
||||
object DesugaredInvertedContains : KtFakeSourceElementKind()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user