[FIR] Add top level invalid destructuring declarations in classes
Part of ^KTIJ-23263 Merge-request: KT-MR-10424 Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
This commit is contained in:
+6
@@ -183,6 +183,12 @@ public class FirOutOfContentRootLazyBodiesCalculatorTestGenerated extends Abstra
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
|
||||
+6
@@ -183,6 +183,12 @@ public class FirSourceLazyBodiesCalculatorTestGenerated extends AbstractFirSourc
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
|
||||
+1
@@ -858,6 +858,7 @@ class DeclarationsConverter(
|
||||
CLASS_INITIALIZER -> container += convertAnonymousInitializer(node) //anonymousInitializer
|
||||
SECONDARY_CONSTRUCTOR -> container += convertSecondaryConstructor(node, classWrapper)
|
||||
MODIFIER_LIST -> modifierLists += node
|
||||
DESTRUCTURING_DECLARATION -> container += buildErrorTopLevelDestructuringDeclaration(node.toFirSourceElement())
|
||||
}
|
||||
}
|
||||
for (node in modifierLists) {
|
||||
|
||||
+5
@@ -166,6 +166,11 @@ public class LightTree2FirConverterTestCaseGenerated extends AbstractLightTree2F
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
||||
|
||||
@@ -342,6 +342,9 @@ open class RawFirBuilder(
|
||||
ownerClassBuilder.ownerRegularClassTypeParametersCount
|
||||
)
|
||||
}
|
||||
is KtDestructuringDeclaration -> {
|
||||
buildErrorTopLevelDestructuringDeclaration(toFirSourceElement())
|
||||
}
|
||||
else -> convert()
|
||||
}
|
||||
}
|
||||
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
val (a, b) = 1 to 2
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
FILE: invalidDestructing.kt
|
||||
public? final? class A : R|kotlin/Any| {
|
||||
public? constructor(): R|A| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
<ERROR PROPERTY: Destructuring declarations are only allowed for local variables/values>
|
||||
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
FILE: invalidDestructing.kt
|
||||
public? final? class A : R|kotlin/Any| {
|
||||
public? [ContainingClassKey=A] constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
<ERROR PROPERTY: Destructuring declarations are only allowed for local variables/values>
|
||||
|
||||
}
|
||||
+5
@@ -166,6 +166,11 @@ public class RawFirBuilderLazyBodiesTestCaseGenerated extends AbstractRawFirBuil
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
||||
|
||||
+5
@@ -166,6 +166,11 @@ public class RawFirBuilderTestCaseGenerated extends AbstractRawFirBuilderTestCas
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
||||
|
||||
@@ -19,13 +19,13 @@ package org.jetbrains.kotlin.psi
|
||||
import com.intellij.lang.ASTNode
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.tree.TokenSet
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.CLASS_BODY
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtStubElementTypes.MODIFIER_LIST
|
||||
import org.jetbrains.kotlin.psi.stubs.elements.KtTokenSets.DECLARATION_TYPES
|
||||
|
||||
class KtClassBody : KtElementImplStub<KotlinPlaceHolderStub<KtClassBody>>, KtDeclarationContainer {
|
||||
private val lBraceTokenSet = TokenSet.create(KtTokens.LBRACE)
|
||||
@@ -37,7 +37,8 @@ class KtClassBody : KtElementImplStub<KotlinPlaceHolderStub<KtClassBody>>, KtDec
|
||||
|
||||
override fun getParent() = parentByStub
|
||||
|
||||
override fun getDeclarations() = listOf(*getStubOrPsiChildren(DECLARATION_TYPES, KtDeclaration.ARRAY_FACTORY))
|
||||
override fun getDeclarations() = stub?.getChildrenByType(KtFile.FILE_DECLARATION_TYPES, KtDeclaration.ARRAY_FACTORY)?.toList()
|
||||
?: PsiTreeUtil.getChildrenOfTypeAsList(this, KtDeclaration::class.java)
|
||||
|
||||
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D) = visitor.visitClassBody(this, data)
|
||||
|
||||
|
||||
+6
@@ -183,6 +183,12 @@ public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizerTe
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
|
||||
+6
@@ -183,6 +183,12 @@ public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizerTe
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("invalidDestructing.kt")
|
||||
public void testInvalidDestructing() throws Exception {
|
||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("nestedClass.kt")
|
||||
public void testNestedClass() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user