[FE] Fix source element duplication in object literal expressions
This commit is contained in:
@@ -45,7 +45,6 @@ internal fun KtExpression.unwrap(): KtExpression {
|
||||
return when (this) {
|
||||
is KtLabeledExpression -> baseExpression?.unwrap()
|
||||
is KtAnnotatedExpression -> baseExpression?.unwrap()
|
||||
is KtObjectLiteralExpression -> objectDeclaration
|
||||
is KtFunctionLiteral -> (parent as? KtLambdaExpression)?.unwrap()
|
||||
else -> this
|
||||
} ?: this
|
||||
|
||||
-1
@@ -44,7 +44,6 @@ internal class FirElementBuilder(
|
||||
// null will be return in case of invalid KtValueArgument
|
||||
deparenthesized.getArgumentExpression()
|
||||
}
|
||||
deparenthesized is KtObjectLiteralExpression -> deparenthesized.objectDeclaration
|
||||
deparenthesized is KtStringTemplateEntryWithExpression -> deparenthesized.expression
|
||||
deparenthesized is KtUserType && deparenthesized.parent is KtNullableType -> deparenthesized.parent as KtNullableType
|
||||
else -> deparenthesized
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtObjectDeclaration
|
||||
|
||||
fun test() {
|
||||
<expr>object {}</expr>
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
KT element: KtObjectDeclaration
|
||||
FIR element: FirAnonymousObjectImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
object : R|kotlin/Any| {
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// LOOK_UP_FOR_ELEMENT_OF_TYPE: org.jetbrains.kotlin.psi.KtObjectLiteralExpression
|
||||
|
||||
fun test() {
|
||||
<expr>object {}</expr>
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
KT element: KtObjectLiteralExpression
|
||||
FIR element: FirAnonymousObjectExpressionImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
object : R|kotlin/Any| {
|
||||
private constructor(): R|<anonymous>| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -215,6 +215,18 @@ public class GetOrBuildFirTestGenerated extends AbstractGetOrBuildFirTest {
|
||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objectLiteral.kt")
|
||||
public void testObjectLiteral() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/objectLiteral.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("objectLiteralExpression.kt")
|
||||
public void testObjectLiteralExpression() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/objectLiteralExpression.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyDelegate.kt")
|
||||
public void testPropertyDelegate() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user