Revert "[FIR] Fix error with incorrect destructing declaration"
This reverts commit b47910e86b.
This commit is contained in:
-6
@@ -311,12 +311,6 @@ internal class KtSymbolByFirBuilder constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun buildErrorVariableSymbol(firSymbol: FirErrorPropertySymbol): KtFirErrorVariableSymbol {
|
|
||||||
return symbolsCache.cache(firSymbol) {
|
|
||||||
KtFirErrorVariableSymbol(firSymbol, analysisSession)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun buildSyntheticJavaPropertySymbol(firSymbol: FirSyntheticPropertySymbol): KtFirSyntheticJavaPropertySymbol {
|
fun buildSyntheticJavaPropertySymbol(firSymbol: FirSyntheticPropertySymbol): KtFirSyntheticJavaPropertySymbol {
|
||||||
return symbolsCache.cache(firSymbol) {
|
return symbolsCache.cache(firSymbol) {
|
||||||
KtFirSyntheticJavaPropertySymbol(firSymbol, analysisSession)
|
KtFirSyntheticJavaPropertySymbol(firSymbol, analysisSession)
|
||||||
|
|||||||
+9
-26
@@ -18,18 +18,18 @@ import org.jetbrains.kotlin.analysis.api.symbols.pointers.CanNotCreateSymbolPoin
|
|||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtPsiBasedSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtPsiBasedSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirErrorProperty
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirVariable
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirErrorPropertySymbol
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirPropertySymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
|
|
||||||
internal abstract class KtFirLocalOrErrorVariableSymbol<E: FirVariable, S: FirVariableSymbol<E>>(
|
internal class KtFirLocalVariableSymbol(
|
||||||
override val firSymbol: S,
|
override val firSymbol: FirPropertySymbol,
|
||||||
override val analysisSession: KtFirAnalysisSession,
|
override val analysisSession: KtFirAnalysisSession,
|
||||||
) : KtLocalVariableSymbol(), KtFirSymbol<S> {
|
) : KtLocalVariableSymbol(),
|
||||||
|
KtFirSymbol<FirPropertySymbol> {
|
||||||
|
init {
|
||||||
|
assert(firSymbol.isLocal)
|
||||||
|
}
|
||||||
|
|
||||||
override val psi: PsiElement? = withValidityAssertion { firSymbol.fir.getAllowedPsi() }
|
override val psi: PsiElement? = withValidityAssertion { firSymbol.fir.getAllowedPsi() }
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
@@ -37,6 +37,7 @@ internal abstract class KtFirLocalOrErrorVariableSymbol<E: FirVariable, S: FirVa
|
|||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override val isVal: Boolean get() = withValidityAssertion { firSymbol.isVal }
|
||||||
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
||||||
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) }
|
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) }
|
||||||
|
|
||||||
@@ -50,22 +51,4 @@ internal abstract class KtFirLocalOrErrorVariableSymbol<E: FirVariable, S: FirVa
|
|||||||
|
|
||||||
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
||||||
override fun hashCode(): Int = symbolHashCode()
|
override fun hashCode(): Int = symbolHashCode()
|
||||||
|
|
||||||
}
|
|
||||||
internal class KtFirLocalVariableSymbol(firSymbol: FirPropertySymbol, analysisSession: KtFirAnalysisSession) :
|
|
||||||
KtFirLocalOrErrorVariableSymbol<FirProperty, FirPropertySymbol>(firSymbol, analysisSession) {
|
|
||||||
init {
|
|
||||||
assert(firSymbol.isLocal)
|
|
||||||
}
|
|
||||||
|
|
||||||
override val isVal: Boolean get() = withValidityAssertion { firSymbol.isVal }
|
|
||||||
}
|
|
||||||
|
|
||||||
internal class KtFirErrorVariableSymbol(
|
|
||||||
firSymbol: FirErrorPropertySymbol,
|
|
||||||
analysisSession: KtFirAnalysisSession,
|
|
||||||
) : KtFirLocalOrErrorVariableSymbol<FirErrorProperty, FirErrorPropertySymbol>(firSymbol, analysisSession),
|
|
||||||
KtFirSymbol<FirErrorPropertySymbol> {
|
|
||||||
override val isVal: Boolean
|
|
||||||
get() = firSymbol.fir.isVal
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-7
@@ -11,7 +11,6 @@ import org.jetbrains.kotlin.analysis.api.getModule
|
|||||||
import org.jetbrains.kotlin.analysis.api.symbols.*
|
import org.jetbrains.kotlin.analysis.api.symbols.*
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirFile
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.resolveToFirSymbolOfType
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.resolveToFirSymbolOfType
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.throwUnexpectedFirElementError
|
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.withFirSymbolEntry
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.withFirSymbolEntry
|
||||||
import org.jetbrains.kotlin.analysis.utils.errors.buildErrorWithAttachment
|
import org.jetbrains.kotlin.analysis.utils.errors.buildErrorWithAttachment
|
||||||
@@ -186,11 +185,9 @@ internal class KtFirSymbolProvider(
|
|||||||
|
|
||||||
override val ROOT_PACKAGE_SYMBOL: KtPackageSymbol = KtFirPackageSymbol(FqName.ROOT, firResolveSession.project, token)
|
override val ROOT_PACKAGE_SYMBOL: KtPackageSymbol = KtFirPackageSymbol(FqName.ROOT, firResolveSession.project, token)
|
||||||
|
|
||||||
override fun getDestructuringDeclarationEntrySymbol(psi: KtDestructuringDeclarationEntry): KtFirLocalOrErrorVariableSymbol<*, *> {
|
override fun getDestructuringDeclarationEntrySymbol(psi: KtDestructuringDeclarationEntry): KtLocalVariableSymbol {
|
||||||
return when (val firSymbol = psi.resolveToFirSymbolOfType<FirVariableSymbol<*>>(firResolveSession)) {
|
return firSymbolBuilder.variableLikeBuilder.buildLocalVariableSymbol(
|
||||||
is FirPropertySymbol -> firSymbolBuilder.variableLikeBuilder.buildLocalVariableSymbol(firSymbol)
|
psi.resolveToFirSymbolOfType<FirPropertySymbol>(firResolveSession)
|
||||||
is FirErrorPropertySymbol -> firSymbolBuilder.variableLikeBuilder.buildErrorVariableSymbol(firSymbol)
|
)
|
||||||
else -> throwUnexpectedFirElementError(firSymbol, psi, FirPropertySymbol::class, FirErrorPropertySymbol::class)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -1 +0,0 @@
|
|||||||
val (<expr>o</expr>, r)
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
KT element: KtDestructuringDeclarationEntry
|
|
||||||
FIR element: FirErrorPropertyImpl
|
|
||||||
FIR source kind: KtRealSourceElementKind
|
|
||||||
|
|
||||||
FIR element rendered:
|
|
||||||
<ERROR PROPERTY: Destructuring declarations are only allowed for local variables/values>
|
|
||||||
-6
@@ -441,12 +441,6 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon
|
|||||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/constructorProperty.kt");
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/constructorProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("destructionWithNoRValue.kt")
|
|
||||||
public void testDestructionWithNoRValue() throws Exception {
|
|
||||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/destructionWithNoRValue.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("destructuring.kt")
|
@TestMetadata("destructuring.kt")
|
||||||
public void testDestructuring() throws Exception {
|
public void testDestructuring() throws Exception {
|
||||||
|
|||||||
-6
@@ -441,12 +441,6 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi
|
|||||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/constructorProperty.kt");
|
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/constructorProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("destructionWithNoRValue.kt")
|
|
||||||
public void testDestructionWithNoRValue() throws Exception {
|
|
||||||
runTest("analysis/low-level-api-fir/testdata/getOrBuildFir/declarations/destructionWithNoRValue.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("destructuring.kt")
|
@TestMetadata("destructuring.kt")
|
||||||
public void testDestructuring() throws Exception {
|
public void testDestructuring() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user