[FIR] Don't miss annotations on inits
^KT-59874
This commit is contained in:
committed by
Space Team
parent
63f461a6cd
commit
5a1a23afac
+5
-2
@@ -112,9 +112,10 @@ private class LLFirTypeTargetResolver(
|
||||
is FirTypeAlias,
|
||||
is FirScript,
|
||||
is FirRegularClass,
|
||||
is FirAnonymousInitializer,
|
||||
-> rawResolve(target)
|
||||
|
||||
is FirFile, is FirAnonymousInitializer, is FirCodeFragment -> {}
|
||||
is FirFile, is FirCodeFragment -> {}
|
||||
else -> errorWithAttachment("Unknown declaration ${target::class.simpleName}") {
|
||||
withFirEntry("declaration", target)
|
||||
}
|
||||
@@ -150,7 +151,9 @@ private class LLFirTypeTargetResolver(
|
||||
target.accept(transformer, null)
|
||||
}
|
||||
is FirScript -> resolveScriptTypes(target)
|
||||
is FirDanglingModifierList, is FirFileAnnotationsContainer, is FirCallableDeclaration, is FirTypeAlias -> {
|
||||
is FirDanglingModifierList, is FirFileAnnotationsContainer, is FirCallableDeclaration, is FirTypeAlias,
|
||||
is FirAnonymousInitializer,
|
||||
-> {
|
||||
target.accept(transformer, null)
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package low
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
annotation class Anno(val position: String)
|
||||
|
||||
const val constant = 0
|
||||
|
||||
class MyClass {
|
||||
@Anno("init annotation: $constant") i<caret>nit {
|
||||
@Anno("annotation inside")
|
||||
funInsideInit()
|
||||
}
|
||||
}
|
||||
|
||||
fun anotherFun(): String = "str"
|
||||
fun funInsideInit() = anotherFun()
|
||||
@@ -0,0 +1,323 @@
|
||||
RAW_FIR:
|
||||
FILE: [ResolvedTo(RAW_FIR)] initWithAnnotation.kt
|
||||
@Target[Unresolved](LAZY_EXPRESSION) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public? final? [ResolvedTo(RAW_FIR)] class MyClass : R|kotlin/Any| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(RAW_FIR)] @Anno[Unresolved](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
IMPORTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@Target[Unresolved](LAZY_EXPRESSION) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public? final? [ResolvedTo(RAW_FIR)] class MyClass : R|kotlin/Any| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(RAW_FIR)] @Anno[Unresolved](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
COMPILER_REQUIRED_ANNOTATIONS:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@Target[Unresolved](LAZY_EXPRESSION) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public? final? [ResolvedTo(RAW_FIR)] class MyClass : R|kotlin/Any| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] @Anno[Unresolved](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
COMPANION_GENERATION:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@Target[Unresolved](LAZY_EXPRESSION) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public? final? [ResolvedTo(RAW_FIR)] class MyClass : R|kotlin/Any| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(COMPANION_GENERATION)] @Anno[Unresolved](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
SUPER_TYPES:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@Target[Unresolved](LAZY_EXPRESSION) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(RAW_FIR)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public? final? [ResolvedTo(SUPER_TYPES)] class MyClass : R|kotlin/Any| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(SUPER_TYPES)] @Anno[Unresolved](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
TYPES:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[CompilerRequiredAnnotations](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public? final? [ResolvedTo(TYPES)] class MyClass : R|kotlin/Any| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(TYPES)] @R|low/Anno|[Types](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
STATUS:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[CompilerRequiredAnnotations](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(STATUS)] @R|low/Anno|[Types](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
EXPECT_ACTUAL_MATCHING:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[CompilerRequiredAnnotations](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(EXPECT_ACTUAL_MATCHING)] @R|low/Anno|[Types](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
CONTRACTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[CompilerRequiredAnnotations](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(CONTRACTS)] @R|low/Anno|[Types](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
IMPLICIT_TYPES_BODY_RESOLVE:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[CompilerRequiredAnnotations](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @Retention[Unresolved](LAZY_EXPRESSION) public? final? [ResolvedTo(COMPILER_REQUIRED_ANNOTATIONS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] constructor([ResolvedTo(RAW_FIR)] [CorrespondingProperty=low/Anno.position] position: String): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public? final? [ResolvedTo(RAW_FIR)] [IsFromPrimaryConstructor=true] val position: String = R|<local>/position|
|
||||
public? [ResolvedTo(RAW_FIR)] [ContainingClassKey=Anno] get(): String
|
||||
|
||||
}
|
||||
public? final? const [ResolvedTo(RAW_FIR)] val constant: <implicit> = LAZY_EXPRESSION
|
||||
public? [ResolvedTo(RAW_FIR)] get(): <implicit>
|
||||
public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] @R|low/Anno|[Types](LAZY_EXPRESSION) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
ANNOTATION_ARGUMENTS:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[Types](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @R|kotlin/annotation/Retention|[Types](LAZY_EXPRESSION) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] constructor([ResolvedTo(STATUS)] [CorrespondingProperty=low/Anno.position] position: R|kotlin/String|): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val position: R|kotlin/String| = R|<local>/position|
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val constant: R|kotlin/Int| = Int(0)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(ANNOTATION_ARGUMENTS)] @R|low/Anno|[Types](position = <strcat>(String(init annotation: ), R|low/constant|)) init { LAZY_BLOCK }
|
||||
|
||||
}
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun anotherFun(): String { LAZY_BLOCK }
|
||||
public? final? [ResolvedTo(RAW_FIR)] fun funInsideInit(): <implicit> { LAZY_BLOCK }
|
||||
|
||||
BODY_RESOLVE:
|
||||
FILE: [ResolvedTo(IMPORTS)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[Types](Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|) @R|kotlin/annotation/Retention|[Types](LAZY_EXPRESSION) public final [ResolvedTo(STATUS)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] constructor([ResolvedTo(STATUS)] [CorrespondingProperty=low/Anno.position] position: R|kotlin/String|): R|low/Anno| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
public final [ResolvedTo(STATUS)] [IsFromPrimaryConstructor=true] val position: R|kotlin/String| = R|<local>/position|
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=Anno] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final const [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] val constant: R|kotlin/Int| = Int(0)
|
||||
public [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public final [ResolvedTo(STATUS)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(STATUS)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
LAZY_super<R|kotlin/Any|>
|
||||
}
|
||||
|
||||
[ResolvedTo(BODY_RESOLVE)] @R|low/Anno|[Types](position = <strcat>(String(init annotation: ), R|low/constant|)) init {
|
||||
@R|low/Anno|[Types](position = String(annotation inside)) R|low/funInsideInit|()
|
||||
}
|
||||
|
||||
}
|
||||
public final [ResolvedTo(CONTRACTS)] fun anotherFun(): R|kotlin/String| {
|
||||
^anotherFun String(str)
|
||||
}
|
||||
public final [ResolvedTo(IMPLICIT_TYPES_BODY_RESOLVE)] fun funInsideInit(): R|kotlin/String| {
|
||||
^funInsideInit R|low/anotherFun|()
|
||||
}
|
||||
|
||||
FILE RAW TO BODY:
|
||||
FILE: [ResolvedTo(BODY_RESOLVE)] initWithAnnotation.kt
|
||||
@R|kotlin/annotation/Target|[Types](allowedTargets = vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.EXPRESSION|)) @R|kotlin/annotation/Retention|[Types](value = Q|kotlin/annotation/AnnotationRetention|.R|kotlin/annotation/AnnotationRetention.SOURCE|) public final [ResolvedTo(BODY_RESOLVE)] annotation class Anno : R|kotlin/Annotation| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Anno] constructor([ResolvedTo(BODY_RESOLVE)] [CorrespondingProperty=low/Anno.position] position: R|kotlin/String|): R|low/Anno| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final [ResolvedTo(BODY_RESOLVE)] [IsFromPrimaryConstructor=true] val position: R|kotlin/String| = R|<local>/position|
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=Anno] get(): R|kotlin/String|
|
||||
|
||||
}
|
||||
public final const [ResolvedTo(BODY_RESOLVE)] val constant: R|kotlin/Int| = Int(0)
|
||||
public [ResolvedTo(BODY_RESOLVE)] get(): R|kotlin/Int|
|
||||
public final [ResolvedTo(BODY_RESOLVE)] class MyClass : R|kotlin/Any| {
|
||||
public [ResolvedTo(BODY_RESOLVE)] [ContainingClassKey=MyClass] constructor(): R|low/MyClass| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
[ResolvedTo(BODY_RESOLVE)] @R|low/Anno|[Types](position = <strcat>(String(init annotation: ), R|low/constant|)) init {
|
||||
@R|low/Anno|[Types](position = String(annotation inside)) R|low/funInsideInit|()
|
||||
}
|
||||
|
||||
}
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun anotherFun(): R|kotlin/String| {
|
||||
^anotherFun String(str)
|
||||
}
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun funInsideInit(): R|kotlin/String| {
|
||||
^funInsideInit R|low/anotherFun|()
|
||||
}
|
||||
+6
@@ -342,6 +342,12 @@ public class FirOutOfContentRootLazyDeclarationResolveTestGenerated extends Abst
|
||||
runTest("analysis/low-level-api-fir/testData/lazyResolve/implicitTypeWithInaccessibleAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initWithAnnotation.kt")
|
||||
public void testInitWithAnnotation() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testData/lazyResolve/initWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaAsSAMInterface.kt")
|
||||
public void testLambdaAsSAMInterface() throws Exception {
|
||||
|
||||
+6
@@ -342,6 +342,12 @@ public class FirSourceLazyDeclarationResolveTestGenerated extends AbstractFirSou
|
||||
runTest("analysis/low-level-api-fir/testData/lazyResolve/implicitTypeWithInaccessibleAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("initWithAnnotation.kt")
|
||||
public void testInitWithAnnotation() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testData/lazyResolve/initWithAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("lambdaAsSAMInterface.kt")
|
||||
public void testLambdaAsSAMInterface() throws Exception {
|
||||
|
||||
+3
@@ -1004,8 +1004,10 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
*/
|
||||
private fun convertAnonymousInitializer(anonymousInitializer: LighterASTNode): FirDeclaration {
|
||||
var firBlock: FirBlock? = null
|
||||
var modifiers = Modifier()
|
||||
anonymousInitializer.forEachChildren {
|
||||
when (it.tokenType) {
|
||||
MODIFIER_LIST -> modifiers = convertModifierList(it, isInClass = true)
|
||||
BLOCK -> withForcedLocalContext {
|
||||
firBlock = convertBlock(it)
|
||||
}
|
||||
@@ -1018,6 +1020,7 @@ class LightTreeRawFirDeclarationBuilder(
|
||||
origin = FirDeclarationOrigin.Source
|
||||
body = firBlock ?: buildEmptyExpressionBlock()
|
||||
dispatchReceiverType = context.dispatchReceiverTypesStack.lastOrNull()
|
||||
annotations += modifiers.annotations
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2110,6 +2110,7 @@ open class PsiRawFirBuilder(
|
||||
}
|
||||
}
|
||||
dispatchReceiverType = context.dispatchReceiverTypesStack.lastOrNull()
|
||||
initializer.extractAnnotationsTo(this)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -164,6 +164,12 @@ open class FirTypeResolveTransformer(
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformAnonymousInitializer(anonymousInitializer: FirAnonymousInitializer, data: Any?): FirAnonymousInitializer {
|
||||
return withScopeCleanup {
|
||||
transformDeclaration(anonymousInitializer, data) as FirAnonymousInitializer
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformErrorPrimaryConstructor(errorPrimaryConstructor: FirErrorPrimaryConstructor, data: Any?) =
|
||||
transformConstructor(errorPrimaryConstructor, data)
|
||||
|
||||
|
||||
+1
@@ -207,6 +207,7 @@ private class FirDeclarationsResolveTransformerForAnnotationArguments(
|
||||
anonymousInitializer: FirAnonymousInitializer,
|
||||
data: ResolutionMode
|
||||
): FirAnonymousInitializer {
|
||||
anonymousInitializer.transformAnnotations(this, ResolutionMode.ContextIndependent)
|
||||
return anonymousInitializer
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -15,6 +15,7 @@ import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirModuleData
|
||||
import org.jetbrains.kotlin.fir.builder.FirAnnotationContainerBuilder
|
||||
import org.jetbrains.kotlin.fir.builder.FirBuilderDsl
|
||||
import org.jetbrains.kotlin.fir.builder.toMutableOrEmpty
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousInitializer
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationAttributes
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclarationOrigin
|
||||
@@ -29,6 +30,7 @@ import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
class FirAnonymousInitializerBuilder : FirDeclarationBuilder, FirAnnotationContainerBuilder {
|
||||
override var source: KtSourceElement? = null
|
||||
override var resolvePhase: FirResolvePhase = FirResolvePhase.RAW_FIR
|
||||
override val annotations: MutableList<FirAnnotation> = mutableListOf()
|
||||
override lateinit var moduleData: FirModuleData
|
||||
override lateinit var origin: FirDeclarationOrigin
|
||||
override var attributes: FirDeclarationAttributes = FirDeclarationAttributes()
|
||||
@@ -40,6 +42,7 @@ class FirAnonymousInitializerBuilder : FirDeclarationBuilder, FirAnnotationConta
|
||||
return FirAnonymousInitializerImpl(
|
||||
source,
|
||||
resolvePhase,
|
||||
annotations.toMutableOrEmpty(),
|
||||
moduleData,
|
||||
origin,
|
||||
attributes,
|
||||
@@ -49,9 +52,6 @@ class FirAnonymousInitializerBuilder : FirDeclarationBuilder, FirAnnotationConta
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@Deprecated("Modification of 'annotations' has no impact for FirAnonymousInitializerBuilder", level = DeprecationLevel.HIDDEN)
|
||||
override val annotations: MutableList<FirAnnotation> = mutableListOf()
|
||||
}
|
||||
|
||||
@OptIn(ExperimentalContracts::class)
|
||||
|
||||
+10
-3
@@ -12,6 +12,8 @@ package org.jetbrains.kotlin.fir.declarations.impl
|
||||
|
||||
import org.jetbrains.kotlin.KtSourceElement
|
||||
import org.jetbrains.kotlin.fir.FirModuleData
|
||||
import org.jetbrains.kotlin.fir.MutableOrEmptyList
|
||||
import org.jetbrains.kotlin.fir.builder.toMutableOrEmpty
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirAnnotation
|
||||
import org.jetbrains.kotlin.fir.expressions.FirBlock
|
||||
@@ -20,11 +22,13 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirAnonymousInitializerSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassLikeType
|
||||
import org.jetbrains.kotlin.fir.visitors.FirTransformer
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
||||
import org.jetbrains.kotlin.fir.visitors.transformInplace
|
||||
|
||||
@OptIn(ResolveStateAccess::class)
|
||||
internal class FirAnonymousInitializerImpl(
|
||||
override val source: KtSourceElement?,
|
||||
resolvePhase: FirResolvePhase,
|
||||
override var annotations: MutableOrEmptyList<FirAnnotation>,
|
||||
override val moduleData: FirModuleData,
|
||||
override val origin: FirDeclarationOrigin,
|
||||
override val attributes: FirDeclarationAttributes,
|
||||
@@ -32,8 +36,6 @@ internal class FirAnonymousInitializerImpl(
|
||||
override val symbol: FirAnonymousInitializerSymbol,
|
||||
override val dispatchReceiverType: ConeClassLikeType?,
|
||||
) : FirAnonymousInitializer() {
|
||||
override val annotations: List<FirAnnotation>
|
||||
get() = emptyList()
|
||||
override var controlFlowGraphReference: FirControlFlowGraphReference? = null
|
||||
|
||||
init {
|
||||
@@ -42,21 +44,26 @@ internal class FirAnonymousInitializerImpl(
|
||||
}
|
||||
|
||||
override fun <R, D> acceptChildren(visitor: FirVisitor<R, D>, data: D) {
|
||||
annotations.forEach { it.accept(visitor, data) }
|
||||
controlFlowGraphReference?.accept(visitor, data)
|
||||
body?.accept(visitor, data)
|
||||
}
|
||||
|
||||
override fun <D> transformChildren(transformer: FirTransformer<D>, data: D): FirAnonymousInitializerImpl {
|
||||
transformAnnotations(transformer, data)
|
||||
controlFlowGraphReference = controlFlowGraphReference?.transform(transformer, data)
|
||||
body = body?.transform(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun <D> transformAnnotations(transformer: FirTransformer<D>, data: D): FirAnonymousInitializerImpl {
|
||||
annotations.transformInplace(transformer, data)
|
||||
return this
|
||||
}
|
||||
|
||||
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {}
|
||||
override fun replaceAnnotations(newAnnotations: List<FirAnnotation>) {
|
||||
annotations = newAnnotations.toMutableOrEmpty()
|
||||
}
|
||||
|
||||
override fun replaceControlFlowGraphReference(newControlFlowGraphReference: FirControlFlowGraphReference?) {
|
||||
controlFlowGraphReference = newControlFlowGraphReference
|
||||
|
||||
@@ -479,6 +479,7 @@ class FirRenderer(
|
||||
|
||||
override fun visitAnonymousInitializer(anonymousInitializer: FirAnonymousInitializer) {
|
||||
resolvePhaseRenderer?.render(anonymousInitializer)
|
||||
annotationRenderer?.render(anonymousInitializer)
|
||||
print("init")
|
||||
bodyRenderer?.renderBody(anonymousInitializer.body)
|
||||
}
|
||||
|
||||
+1
-3
@@ -43,9 +43,7 @@ object ImplementationConfigurator : AbstractFirTreeImplementationConfigurator()
|
||||
defaultFalse("hasLazyNestedClassifiers", withGetter = true)
|
||||
}
|
||||
|
||||
impl(anonymousInitializer) {
|
||||
defaultEmptyList("annotations")
|
||||
}
|
||||
impl(anonymousInitializer)
|
||||
|
||||
impl(anonymousObject)
|
||||
impl(danglingModifierList)
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class A {
|
||||
@ann init {}
|
||||
@aaa init {}
|
||||
<!WRONG_ANNOTATION_TARGET!>@ann<!> init {}
|
||||
@<!UNRESOLVED_REFERENCE!>aaa<!> init {}
|
||||
}
|
||||
|
||||
interface T {
|
||||
@ann <!ANONYMOUS_INITIALIZER_IN_INTERFACE!>init<!> {}
|
||||
@aaa <!ANONYMOUS_INITIALIZER_IN_INTERFACE!>init<!> {}
|
||||
<!WRONG_ANNOTATION_TARGET!>@ann<!> <!ANONYMOUS_INITIALIZER_IN_INTERFACE!>init<!> {}
|
||||
@<!UNRESOLVED_REFERENCE!>aaa<!> <!ANONYMOUS_INITIALIZER_IN_INTERFACE!>init<!> {}
|
||||
}
|
||||
|
||||
annotation class ann
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
annotation class base
|
||||
|
||||
@base class My {
|
||||
@base init {
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
annotation class base
|
||||
|
||||
@base class My {
|
||||
|
||||
@@ -85,9 +85,9 @@ abstract class IllegalModifiers6() {
|
||||
<!WRONG_MODIFIER_TARGET!>open<!> init {}
|
||||
<!WRONG_MODIFIER_TARGET!>final<!> init {}
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>public<!> @annotated init {}
|
||||
<!WRONG_MODIFIER_TARGET!>public<!> <!WRONG_ANNOTATION_TARGET!>@annotated<!> init {}
|
||||
|
||||
<!WRONG_MODIFIER_TARGET!>private<!> @IllegalModifiers6() init {}
|
||||
<!WRONG_MODIFIER_TARGET!>private<!> <!WRONG_ANNOTATION_TARGET!>@<!NOT_AN_ANNOTATION_CLASS!>IllegalModifiers6<!>()<!> init {}
|
||||
}
|
||||
|
||||
// strange inappropriate modifiers usages
|
||||
|
||||
Reference in New Issue
Block a user