[FIR] Pass annotations to buildResolvedQualifierForClass

This commit is contained in:
Ivan Kochurkin
2022-06-04 21:56:35 +03:00
committed by teamcity
parent 1ac4d68433
commit c5648fd449
4 changed files with 17 additions and 4 deletions
@@ -362,7 +362,8 @@ class FirCallResolver(
qualifiedAccess.explicitReceiver,
referencedSymbol,
nonFatalDiagnosticFromExpression,
)
),
annotations = qualifiedAccess.annotations
)
}
referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> {
@@ -146,7 +146,8 @@ fun BodyResolveComponents.buildResolvedQualifierForClass(
// TODO: Clarify if we actually need type arguments for qualifier?
typeArgumentsForQualifier: List<FirTypeProjection> = emptyList(),
diagnostic: ConeDiagnostic? = null,
nonFatalDiagnostics: List<ConeDiagnostic> = emptyList()
nonFatalDiagnostics: List<ConeDiagnostic> = emptyList(),
annotations: List<FirAnnotation> = emptyList()
): FirResolvedQualifier {
val classId = regularClass.classId
@@ -163,6 +164,7 @@ fun BodyResolveComponents.buildResolvedQualifierForClass(
typeArguments.addAll(typeArgumentsForQualifier)
symbol = regularClass
this.nonFatalDiagnostics.addAll(nonFatalDiagnostics)
this.annotations.addAll(annotations)
}.build().apply {
resultType = if (classId.isLocal) {
typeForQualifierByDeclaration(regularClass.fir, resultType, session)
@@ -10,5 +10,7 @@ fun test(x: String?) {
@Ann() @Ann2() { Unit } // It should be Block with annotations
if (x != null)
@Ann() @Ann2() Unit // It should be SingleExpressionBlock with annotations
}
<!WRONG_ANNOTATION_TARGET!>@Ann()<!> <!WRONG_ANNOTATION_TARGET!>@Ann2()<!> Unit // Annotations on expression
<!WRONG_ANNOTATION_TARGET!>@Ann()<!> <!WRONG_ANNOTATION_TARGET!>@Ann2()<!> x
}
@@ -8,3 +8,11 @@ public final annotation class Ann : kotlin.Annotation {
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final annotation class Ann2 : kotlin.Annotation {
public constructor Ann2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}