[FIR] add missed scope for annotations on property receiver, typealias and init and dangling list
Also, we shouldn't transform type alias during the implicit type phase ^KT-63042 ^KT-63832 Fixed
This commit is contained in:
committed by
Space Team
parent
aaaf35fcb8
commit
98e12b0d7b
+9
@@ -424,6 +424,15 @@ abstract class FirAbstractBodyResolveTransformerDispatcher(
|
||||
FirDeclarationsResolveTransformer::transformEnumEntry,
|
||||
)
|
||||
|
||||
override fun transformDanglingModifierList(
|
||||
danglingModifierList: FirDanglingModifierList,
|
||||
data: ResolutionMode,
|
||||
): FirDanglingModifierList = declarationTransformation(
|
||||
danglingModifierList,
|
||||
data,
|
||||
FirDeclarationsResolveTransformer::transformDanglingModifierList,
|
||||
)
|
||||
|
||||
override fun transformProperty(
|
||||
property: FirProperty,
|
||||
data: ResolutionMode,
|
||||
|
||||
+6
@@ -111,6 +111,11 @@ open class FirDeclarationsResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformDanglingModifierList(
|
||||
danglingModifierList: FirDanglingModifierList,
|
||||
data: ResolutionMode
|
||||
): FirDanglingModifierList = danglingModifierList
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: ResolutionMode): FirProperty = whileAnalysing(session, property) {
|
||||
require(property !is FirSyntheticProperty) { "Synthetic properties should not be processed by body transformers" }
|
||||
|
||||
@@ -682,6 +687,7 @@ open class FirDeclarationsResolveTransformer(
|
||||
}
|
||||
|
||||
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: ResolutionMode): FirTypeAlias = whileAnalysing(session, typeAlias) {
|
||||
if (implicitTypeOnly) return typeAlias
|
||||
if (typeAlias.isLocal && typeAlias !in context.targetedLocalClasses) {
|
||||
return typeAlias.runAllPhasesForLocalClass(transformer, components, data, transformer.firResolveContextCollector)
|
||||
}
|
||||
|
||||
+25
-7
@@ -207,7 +207,11 @@ private class FirDeclarationsResolveTransformerForAnnotationArguments(
|
||||
anonymousInitializer: FirAnonymousInitializer,
|
||||
data: ResolutionMode
|
||||
): FirAnonymousInitializer {
|
||||
anonymousInitializer.transformAnnotations(this, ResolutionMode.ContextIndependent)
|
||||
@OptIn(PrivateForInline::class)
|
||||
context.withContainer(anonymousInitializer) {
|
||||
anonymousInitializer.transformAnnotations(this, ResolutionMode.ContextIndependent)
|
||||
}
|
||||
|
||||
return anonymousInitializer
|
||||
}
|
||||
|
||||
@@ -260,8 +264,6 @@ private class FirDeclarationsResolveTransformerForAnnotationArguments(
|
||||
}
|
||||
|
||||
override fun transformProperty(property: FirProperty, data: ResolutionMode): FirProperty {
|
||||
property.transformReceiverParameter(transformer, ResolutionMode.ContextIndependent)
|
||||
|
||||
context.withProperty(property) {
|
||||
property
|
||||
.transformTypeParameters(transformer, data)
|
||||
@@ -320,14 +322,30 @@ private class FirDeclarationsResolveTransformerForAnnotationArguments(
|
||||
}
|
||||
|
||||
override fun transformTypeAlias(typeAlias: FirTypeAlias, data: ResolutionMode): FirTypeAlias {
|
||||
doTransformTypeParameters(typeAlias)
|
||||
typeAlias.transformAnnotations(transformer, data)
|
||||
transformer.firResolveContextCollector?.addDeclarationContext(typeAlias, context)
|
||||
typeAlias.expandedTypeRef.transformSingle(transformer, data)
|
||||
@OptIn(PrivateForInline::class)
|
||||
context.withContainer(typeAlias) {
|
||||
doTransformTypeParameters(typeAlias)
|
||||
typeAlias.transformAnnotations(transformer, data)
|
||||
transformer.firResolveContextCollector?.addDeclarationContext(typeAlias, context)
|
||||
typeAlias.expandedTypeRef.transformSingle(transformer, data)
|
||||
}
|
||||
|
||||
return typeAlias
|
||||
}
|
||||
|
||||
override fun transformScript(script: FirScript, data: ResolutionMode): FirScript {
|
||||
return script
|
||||
}
|
||||
|
||||
override fun transformDanglingModifierList(
|
||||
danglingModifierList: FirDanglingModifierList,
|
||||
data: ResolutionMode
|
||||
): FirDanglingModifierList {
|
||||
@OptIn(PrivateForInline::class)
|
||||
context.withContainer(danglingModifierList) {
|
||||
danglingModifierList.transformAnnotations(transformer, data)
|
||||
}
|
||||
|
||||
return danglingModifierList
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
interface OriginalInterface {
|
||||
companion object {
|
||||
private const val prop = 0
|
||||
}
|
||||
|
||||
@Anno("dangling $<!UNRESOLVED_REFERENCE!>prop<!>")<!SYNTAX!><!>
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
interface OriginalInterface {
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
class MyClass {
|
||||
<!WRONG_ANNOTATION_TARGET!>@Anno("init $<!UNRESOLVED_REFERENCE!>prop<!>")<!> init {
|
||||
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val prop = 0
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
class MyClass {
|
||||
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS, AnnotationTarget.TYPE_PARAMETER)
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
interface OriginalInterface<T> {
|
||||
<!TOPLEVEL_TYPEALIASES_ONLY!>@Anno("alias $<!UNRESOLVED_REFERENCE!>prop<!>")
|
||||
typealias NestedTypeAlias <@Anno("type param $<!UNRESOLVED_REFERENCE!>prop<!>") A : <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>@Anno("bound $<!UNRESOLVED_REFERENCE!>prop<!>") Number<!>> = @Anno("type $<!UNRESOLVED_REFERENCE!>prop<!>") OriginalInterface<A><!>
|
||||
|
||||
companion object {
|
||||
private const val prop = 0
|
||||
}
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
@Target(AnnotationTarget.TYPE, AnnotationTarget.TYPEALIAS, AnnotationTarget.TYPE_PARAMETER)
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ annotation class Anno(val position: String)
|
||||
interface OriginalInterface {
|
||||
@Anno("explicitType $prop")
|
||||
fun <@Anno("type param $prop") F : @Anno("bound $prop") List<@Anno("nested bound $prop") List<@Anno("nested nested bound $prop") String>>> @receiver:Anno("receiver annotation: $prop") @Anno("receiver type $prop") Collection<@Anno("nested receiver type $prop") List<@Anno("nested nested receiver type $prop")String>>.explicitType(@Anno("parameter annotation $prop") param: @Anno("parameter type $prop") ListIterator<@Anno("nested parameter type $prop") List<@Anno("nested nested parameter type $prop")String>>): @Anno("explicitType return type $prop") List<@Anno("explicitType nested return type $prop") List<@Anno("explicitType nested nested return type $prop") Int>> = emptyList()
|
||||
val <@Anno("type param $prop") F : @Anno("bound $prop") Number> @receiver:Anno("receiver annotation: $<!UNRESOLVED_REFERENCE!>prop<!>") @Anno("receiver type $<!UNRESOLVED_REFERENCE!>prop<!>") F.explicitType: @Anno("bound $prop") Int get() = 1
|
||||
val <@Anno("type param $prop") F : @Anno("bound $prop") Number> @receiver:Anno("receiver annotation: $prop") @Anno("receiver type $prop") F.explicitType: @Anno("bound $prop") Int get() = 1
|
||||
|
||||
companion object {
|
||||
private const val prop = 0
|
||||
|
||||
Reference in New Issue
Block a user