[SLC] KT-54804 Erase type and drop receiver annotations in $annotations methods
This commit is contained in:
committed by
Space Team
parent
6d06f29326
commit
0ef31501b1
+11
-19
@@ -21,12 +21,11 @@ import org.jetbrains.kotlin.light.classes.symbol.annotations.*
|
||||
import org.jetbrains.kotlin.light.classes.symbol.classes.SymbolLightClassBase
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.InitializedModifiersBox
|
||||
import org.jetbrains.kotlin.light.classes.symbol.modifierLists.SymbolLightMemberModifierList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.parameters.SymbolLightParameterForReceiver
|
||||
import org.jetbrains.kotlin.light.classes.symbol.parameters.SymbolLightParameterList
|
||||
import org.jetbrains.kotlin.light.classes.symbol.parameters.SymbolLightTypeParameterList
|
||||
import org.jetbrains.kotlin.load.java.JvmAbi
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||
|
||||
internal class SymbolLightAnnotationsMethod private constructor(
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
@@ -115,27 +114,20 @@ internal class SymbolLightAnnotationsMethod private constructor(
|
||||
}
|
||||
|
||||
override fun hashCode(): Int = containingPropertyDeclaration.hashCode()
|
||||
|
||||
private val _typeParameterList: PsiTypeParameterList? by lazyPub {
|
||||
hasTypeParameters().ifTrue {
|
||||
SymbolLightTypeParameterList(
|
||||
owner = this,
|
||||
symbolWithTypeParameterPointer = containingPropertySymbolPointer,
|
||||
ktModule = ktModule,
|
||||
ktDeclaration = containingPropertyDeclaration,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun hasTypeParameters(): Boolean = hasTypeParameters(ktModule, containingPropertyDeclaration, containingPropertySymbolPointer)
|
||||
override fun getTypeParameterList(): PsiTypeParameterList? = _typeParameterList
|
||||
override fun getTypeParameters(): Array<PsiTypeParameter> = _typeParameterList?.typeParameters ?: PsiTypeParameter.EMPTY_ARRAY
|
||||
override fun hasTypeParameters(): Boolean = false
|
||||
override fun getTypeParameterList(): PsiTypeParameterList? = null
|
||||
override fun getTypeParameters(): Array<PsiTypeParameter> = PsiTypeParameter.EMPTY_ARRAY
|
||||
|
||||
private val _parametersList by lazyPub {
|
||||
SymbolLightParameterList(
|
||||
parent = this@SymbolLightAnnotationsMethod,
|
||||
callableWithReceiverSymbolPointer = containingPropertySymbolPointer,
|
||||
parameterPopulator = {},
|
||||
parameterPopulator = { builder ->
|
||||
SymbolLightParameterForReceiver.tryGet(
|
||||
callableSymbolPointer = containingPropertySymbolPointer,
|
||||
method = this@SymbolLightAnnotationsMethod,
|
||||
forPropertyAnnotations = true
|
||||
)?.let(builder::addParameter)
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
+12
-4
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.light.classes.symbol.parameters
|
||||
import com.intellij.psi.PsiIdentifier
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import com.intellij.psi.PsiType
|
||||
import com.intellij.psi.util.TypeConversionUtil
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtCallableSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtReceiverParameterSymbol
|
||||
@@ -26,6 +27,7 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
private val receiverPointer: KtSymbolPointer<KtReceiverParameterSymbol>,
|
||||
methodName: String,
|
||||
method: SymbolLightMethodBase,
|
||||
private val forPropertyAnnotations: Boolean
|
||||
) : SymbolLightParameterBase(method) {
|
||||
private inline fun <T> withReceiverSymbol(crossinline action: context(KtAnalysisSession) (KtReceiverParameterSymbol) -> T): T =
|
||||
receiverPointer.withSymbol(ktModule, action)
|
||||
@@ -33,7 +35,8 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
companion object {
|
||||
fun tryGet(
|
||||
callableSymbolPointer: KtSymbolPointer<KtCallableSymbol>,
|
||||
method: SymbolLightMethodBase
|
||||
method: SymbolLightMethodBase,
|
||||
forPropertyAnnotations: Boolean = false
|
||||
): SymbolLightParameterForReceiver? = callableSymbolPointer.withSymbol(method.ktModule) { callableSymbol ->
|
||||
if (callableSymbol !is KtNamedSymbol) return@withSymbol null
|
||||
if (!callableSymbol.isExtension) return@withSymbol null
|
||||
@@ -43,12 +46,13 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
receiverPointer = receiverSymbol.createPointer(),
|
||||
methodName = callableSymbol.name.asString(),
|
||||
method = method,
|
||||
forPropertyAnnotations = forPropertyAnnotations,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private val _name: String by lazyPub {
|
||||
AsmUtil.getLabeledThisName(methodName, AsmUtil.LABELED_THIS_PARAMETER, AsmUtil.RECEIVER_PARAMETER_NAME)
|
||||
if (forPropertyAnnotations) "p0" else AsmUtil.getLabeledThisName(methodName, AsmUtil.LABELED_THIS_PARAMETER, AsmUtil.RECEIVER_PARAMETER_NAME)
|
||||
}
|
||||
|
||||
override fun getNameIdentifier(): PsiIdentifier? = null
|
||||
@@ -63,7 +67,9 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
override fun getModifierList(): PsiModifierList = _modifierList
|
||||
|
||||
private val _modifierList: PsiModifierList by lazyPub {
|
||||
SymbolLightClassModifierList(
|
||||
if (forPropertyAnnotations)
|
||||
SymbolLightClassModifierList(containingDeclaration = this)
|
||||
else SymbolLightClassModifierList(
|
||||
containingDeclaration = this,
|
||||
annotationsBox = GranularAnnotationsBox(
|
||||
annotationsProvider = SymbolAnnotationsProvider(
|
||||
@@ -83,9 +89,10 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
private val _type: PsiType by lazyPub {
|
||||
withReceiverSymbol { receiver ->
|
||||
val ktType = receiver.type
|
||||
ktType.asPsiTypeElement(this, allowErrorTypes = true)?.let {
|
||||
val psiType = ktType.asPsiTypeElement(this, allowErrorTypes = true)?.let {
|
||||
annotateByKtType(it.type, ktType, it, modifierList)
|
||||
}
|
||||
if (forPropertyAnnotations) TypeConversionUtil.erasure(psiType) else psiType
|
||||
} ?: nonExistentType()
|
||||
}
|
||||
|
||||
@@ -94,6 +101,7 @@ internal class SymbolLightParameterForReceiver private constructor(
|
||||
override fun equals(other: Any?): Boolean = this === other ||
|
||||
other is SymbolLightParameterForReceiver &&
|
||||
ktModule == other.ktModule &&
|
||||
forPropertyAnnotations == other.forPropertyAnnotations &&
|
||||
compareSymbolPointers(receiverPointer, other.receiverPointer)
|
||||
|
||||
override fun hashCode(): Int = _name.hashCode()
|
||||
|
||||
+6
@@ -270,6 +270,12 @@ public class SymbolLightClassesByPsiForLibraryTestGenerated extends AbstractSymb
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -270,6 +270,12 @@ public class SymbolLightClassesEqualityByPsiForLibraryTestGenerated extends Abst
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -270,6 +270,12 @@ public class SymbolLightClassesParentingByPsiForLibraryTestGenerated extends Abs
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -270,6 +270,12 @@ public class SymbolLightClassesByPsiForSourceTestGenerated extends AbstractSymbo
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -270,6 +270,12 @@ public class SymbolLightClassesEqualityByPsiForSourceTestGenerated extends Abstr
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
+6
@@ -270,6 +270,12 @@ public class SymbolLightClassesParentingByPsiForSourceTestGenerated extends Abst
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/properties.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("propertyAnnotations.kt")
|
||||
public void testPropertyAnnotations() throws Exception {
|
||||
runTest("compiler/testData/asJava/lightClasses/lightClassByPsi/propertyAnnotations.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simpleFunctions.kt")
|
||||
public void testSimpleFunctions() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user