[FIR] Do not get expressions from contract effect list in lazy mode

Eleventh step for ^KT-52615
This commit is contained in:
Egor Kulikov
2023-02-16 17:36:50 +01:00
committed by Space Team
parent c564dd973b
commit d670e5a695
5 changed files with 15 additions and 16 deletions
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.builder
import com.intellij.psi.PsiElement import com.intellij.psi.PsiElement
import com.intellij.psi.tree.IElementType import com.intellij.psi.tree.IElementType
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.util.AstLoadingFilter import com.intellij.util.AstLoadingFilter
import org.jetbrains.kotlin.* import org.jetbrains.kotlin.*
import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.builtins.StandardNames
@@ -1527,8 +1526,11 @@ open class RawFirBuilder(
} }
private fun KtContractEffectList.extractRawEffects(destination: MutableList<FirExpression>) { private fun KtContractEffectList.extractRawEffects(destination: MutableList<FirExpression>) {
getExpressions() getContractEffects().mapTo(destination) { effect ->
.mapTo(destination) { it.accept(this@Visitor, Unit) as FirExpression } buildOrLazyExpression(effect.toFirSourceElement()) {
effect.getExpression().accept(this@Visitor, Unit) as FirExpression
}
}
} }
override fun visitLambdaExpression(expression: KtLambdaExpression, data: Unit): FirElement { override fun visitLambdaExpression(expression: KtLambdaExpression, data: Unit): FirElement {
@@ -1,6 +1,6 @@
FILE: functionWithBothOldAndNewSyntaxContractDescription.kt FILE: functionWithBothOldAndNewSyntaxContractDescription.kt
public? final? fun test1(s: String?): R|kotlin/Unit| public? final? fun test1(s: String?): R|kotlin/Unit|
[Contract description] < [Contract description] <
returnsNotNull#() LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
@@ -7,7 +7,7 @@ FILE: propertyAccessorsContractDescription.kt
public? final? var myInt: Int = LAZY_EXPRESSION public? final? var myInt: Int = LAZY_EXPRESSION
public? get(): Int public? get(): Int
[Contract description] < [Contract description] <
returnsNotNull#() LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
public? set(value: Int): R|kotlin/Unit| { LAZY_BLOCK } public? set(value: Int): R|kotlin/Unit| { LAZY_BLOCK }
@@ -21,12 +21,12 @@ FILE: propertyAccessorsContractDescription.kt
public? final? var anotherInt: Int = LAZY_EXPRESSION public? final? var anotherInt: Int = LAZY_EXPRESSION
public? get(): Int public? get(): Int
[Contract description] < [Contract description] <
returnsNotNull#() LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
public? set(value: Int): R|kotlin/Unit| public? set(value: Int): R|kotlin/Unit|
[Contract description] < [Contract description] <
returns#() LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
@@ -39,12 +39,12 @@ FILE: propertyAccessorsContractDescription.kt
public? final? var someInt: Int = LAZY_EXPRESSION public? final? var someInt: Int = LAZY_EXPRESSION
public? get(): Int public? get(): Int
[Contract description] < [Contract description] <
returnsNotNull#() LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
public? set(value: Int): R|kotlin/Unit| public? set(value: Int): R|kotlin/Unit|
[Contract description] < [Contract description] <
returns#().implies#(!=(value#, Null(null))) LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
@@ -1,12 +1,12 @@
FILE: simpleFunctionsContractDescription.kt FILE: simpleFunctionsContractDescription.kt
public? final? fun test1(s: MyClass?): R|kotlin/Unit| public? final? fun test1(s: MyClass?): R|kotlin/Unit|
[Contract description] < [Contract description] <
returns#().implies#(!=(s#, Null(null))), LAZY_EXPRESSION,
returns#().implies#((s# is MySubClass)) LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
public? final? fun test2(): R|kotlin/Unit| public? final? fun test2(): R|kotlin/Unit|
[Contract description] < [Contract description] <
returnsNotNull#() LAZY_EXPRESSION
> >
{ LAZY_BLOCK } { LAZY_BLOCK }
@@ -14,8 +14,5 @@ class KtContractEffectList : KtElementImplStub<KotlinPlaceHolderStub<KtContractE
constructor(stub: KotlinPlaceHolderStub<KtContractEffectList>) : super(stub, KtStubElementTypes.CONTRACT_EFFECT_LIST) constructor(stub: KotlinPlaceHolderStub<KtContractEffectList>) : super(stub, KtStubElementTypes.CONTRACT_EFFECT_LIST)
} }
fun KtContractEffectList.getExpressions(): List<KtExpression> = fun KtContractEffectList.getContractEffects(): List<KtContractEffect> =
getStubOrPsiChildrenAsList(KtStubElementTypes.CONTRACT_EFFECT) getStubOrPsiChildrenAsList(KtStubElementTypes.CONTRACT_EFFECT)
.map {
it.getExpression()
}