[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 {
|
||||
|
||||
@@ -126,10 +126,6 @@ public final class F /* F*/ implements java.lang.Runnable {
|
||||
@Anno(p = "f")
|
||||
public final void f(@Anno() @org.jetbrains.annotations.NotNull() java.lang.String);// f(java.lang.String)
|
||||
|
||||
@Anno(p = "p")
|
||||
@java.lang.Deprecated()
|
||||
public static void getProp$annotations();// getProp$annotations()
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public final java.lang.String getProp();// getProp()
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
// !GENERATE_PROPERTY_ANNOTATIONS_METHODS
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
@Target(*[AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.VALUE_PARAMETER, AnnotationTarget.EXPRESSION])
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface Anno /* Anno*/ {
|
||||
public abstract java.lang.String p() default "";// p()
|
||||
}
|
||||
|
||||
public final class C /* C*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final C.Companion Companion;
|
||||
|
||||
private static final int x = 1 /* initializer type: int */;
|
||||
|
||||
private static final int y = 2 /* initializer type: int */;
|
||||
|
||||
public C();// .ctor()
|
||||
|
||||
public static final int getY();// getY()
|
||||
|
||||
class Companion ...
|
||||
}
|
||||
|
||||
public static final class Companion /* C.Companion*/ {
|
||||
@Anno(p = "x")
|
||||
@java.lang.Deprecated()
|
||||
public static void getX$annotations();// getX$annotations()
|
||||
|
||||
@Anno(p = "y")
|
||||
@java.lang.Deprecated()
|
||||
@kotlin.jvm.JvmStatic()
|
||||
public static void getY$annotations();// getY$annotations()
|
||||
|
||||
private Companion();// .ctor()
|
||||
|
||||
public final int getX();// getX()
|
||||
|
||||
public final int getY();// getY()
|
||||
}
|
||||
|
||||
public final class PropertyAnnotationsKt /* PropertyAnnotationsKt*/ {
|
||||
@kotlin.jvm.Transient()
|
||||
@kotlin.jvm.Volatile()
|
||||
private static transient volatile int jvmFlags = 0 /* initializer type: int */;
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private static final java.lang.String nonNullable = "" /* initializer type: java.lang.String */;
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private static final java.lang.String nullable = null /* initializer type: null */;
|
||||
|
||||
private static final int deprecated = 0 /* initializer type: int */;
|
||||
|
||||
@Anno(p = "nonNullable")
|
||||
@java.lang.Deprecated()
|
||||
public static void getNonNullable$annotations();// getNonNullable$annotations()
|
||||
|
||||
@Anno(p = "nullable")
|
||||
@java.lang.Deprecated()
|
||||
public static void getNullable$annotations();// getNullable$annotations()
|
||||
|
||||
@Anno(p = "propery")
|
||||
@java.lang.Deprecated()
|
||||
public static void getExtensionProperty$annotations(java.util.List);// getExtensionProperty$annotations(java.util.List)
|
||||
|
||||
@java.lang.Deprecated()
|
||||
@kotlin.Deprecated(message = "deprecated")
|
||||
public static void getDeprecated$annotations();// getDeprecated$annotations()
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getNonNullable();// getNonNullable()
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public static final java.lang.String getNullable();// getNullable()
|
||||
|
||||
public static final <T> int getExtensionProperty(@Anno(p = "receiver") @org.jetbrains.annotations.NotNull() java.util.List<? extends T>);// <T> getExtensionProperty(java.util.List<? extends T>)
|
||||
|
||||
public static final int getDeprecated();// getDeprecated()
|
||||
|
||||
public static final int getJvmFlags();// getJvmFlags()
|
||||
|
||||
public static final void setJvmFlags(int);// setJvmFlags(int)
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface Anno /* Anno*/ {
|
||||
public abstract java.lang.String p() default "";// p()
|
||||
}
|
||||
|
||||
public final class C /* C*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final C.Companion Companion;
|
||||
|
||||
private static final int x;
|
||||
|
||||
private static final int y;
|
||||
|
||||
public C();// .ctor()
|
||||
|
||||
public static final int getY();// getY()
|
||||
|
||||
class Companion ...
|
||||
}
|
||||
|
||||
public static final class Companion /* C.Companion*/ {
|
||||
private Companion();// .ctor()
|
||||
|
||||
public final int getX();// getX()
|
||||
|
||||
public final int getY();// getY()
|
||||
}
|
||||
|
||||
public final class PropertyAnnotationsKt /* PropertyAnnotationsKt*/ {
|
||||
@kotlin.jvm.Transient()
|
||||
@kotlin.jvm.Volatile()
|
||||
private static transient volatile int jvmFlags;
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private static final java.lang.String nonNullable;
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private static final java.lang.String nullable;
|
||||
|
||||
private static final int deprecated;
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getNonNullable();// getNonNullable()
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public static final java.lang.String getNullable();// getNullable()
|
||||
|
||||
public static final <T> int getExtensionProperty(@Anno(p = "receiver") @org.jetbrains.annotations.NotNull() java.util.List<? extends T>);// <T> getExtensionProperty(java.util.List<? extends T>)
|
||||
|
||||
public static final int getDeprecated();// getDeprecated()
|
||||
|
||||
public static final int getJvmFlags();// getJvmFlags()
|
||||
|
||||
public static final void setJvmFlags(int);// setJvmFlags(int)
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// !GENERATE_PROPERTY_ANNOTATIONS_METHODS
|
||||
|
||||
annotation class Anno(val p: String = "")
|
||||
|
||||
|
||||
@Deprecated("deprecated")
|
||||
val deprecated = 0
|
||||
|
||||
@Volatile
|
||||
@Transient
|
||||
var jvmFlags = 0
|
||||
|
||||
class C {
|
||||
companion object {
|
||||
@Anno("x")
|
||||
val x = 1
|
||||
|
||||
@JvmStatic
|
||||
@Anno("y")
|
||||
val y = 2
|
||||
}
|
||||
}
|
||||
|
||||
@Anno("propery")
|
||||
val <T: Any> @receiver:Anno("receiver") List<T>.extensionProperty: Int
|
||||
get() = 0
|
||||
|
||||
@Anno("nullable")
|
||||
val nullable: String? = null
|
||||
|
||||
@Anno("nonNullable")
|
||||
val nonNullable: String = ""
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
@java.lang.annotation.Retention(value = java.lang.annotation.RetentionPolicy.RUNTIME)
|
||||
public abstract @interface Anno /* Anno*/ {
|
||||
public abstract java.lang.String p() default "";// p()
|
||||
}
|
||||
|
||||
public final class C /* C*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final C.Companion Companion;
|
||||
|
||||
private static final int x;
|
||||
|
||||
private static final int y;
|
||||
|
||||
public C();// .ctor()
|
||||
|
||||
public static final int getY();// getY()
|
||||
|
||||
class Companion ...
|
||||
}
|
||||
|
||||
public static final class Companion /* C.Companion*/ {
|
||||
private Companion();// .ctor()
|
||||
|
||||
public final int getX();// getX()
|
||||
|
||||
public final int getY();// getY()
|
||||
}
|
||||
|
||||
public final class PropertyAnnotationsKt /* PropertyAnnotationsKt*/ {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
private static final java.lang.String nonNullable;
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
private static final java.lang.String nullable;
|
||||
|
||||
private static final int deprecated;
|
||||
|
||||
private static transient volatile int jvmFlags;
|
||||
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final java.lang.String getNonNullable();// getNonNullable()
|
||||
|
||||
@org.jetbrains.annotations.Nullable()
|
||||
public static final java.lang.String getNullable();// getNullable()
|
||||
|
||||
public static final <T> int getExtensionProperty(@Anno(p = "receiver") @org.jetbrains.annotations.NotNull() java.util.List<? extends T>);// <T> getExtensionProperty(java.util.List<? extends T>)
|
||||
|
||||
public static final int getDeprecated();// getDeprecated()
|
||||
|
||||
public static final int getJvmFlags();// getJvmFlags()
|
||||
|
||||
public static final void setJvmFlags(int);// setJvmFlags(int)
|
||||
}
|
||||
Reference in New Issue
Block a user