diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index aa769f32a2e..9fc0edf7e61 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -1529,10 +1529,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } public KotlinTypeInfo visitAnnotatedExpression(KtAnnotatedExpression expression, ExpressionTypingContext context, boolean isStatement) { - if (!(expression.getBaseExpression() instanceof KtObjectLiteralExpression)) { - // annotations on object literals are resolved later inside LazyClassDescriptor - components.annotationResolver.resolveAnnotationsWithArguments(context.scope, expression.getAnnotationEntries(), context.trace); - } + resolveAnnotationsOnExpression(expression, context); KtExpression baseExpression = expression.getBaseExpression(); if (baseExpression == null) { @@ -1541,6 +1538,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { return facade.getTypeInfo(baseExpression, context, isStatement); } + protected void resolveAnnotationsOnExpression(KtAnnotatedExpression expression, ExpressionTypingContext context) { + if (!(expression.getBaseExpression() instanceof KtObjectLiteralExpression)) { + // annotations on object literals are resolved later inside LazyClassDescriptor + components.annotationResolver.resolveAnnotationsWithArguments(context.scope, expression.getAnnotationEntries(), context.trace); + } + } + @Override public KotlinTypeInfo visitKtElement(@NotNull KtElement element, ExpressionTypingContext context) { context.trace.report(UNSUPPORTED.on(element, getClass().getCanonicalName())); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java index 6e0dbea8f5a..3ddabffd652 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/ExpressionTypingVisitorForStatements.java @@ -309,10 +309,7 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceScope(scope).replaceContextDependency(INDEPENDENT); KtExpression leftOperand = expression.getLeft(); if (leftOperand instanceof KtAnnotatedExpression) { - // We will lose all annotations during deparenthesizing, so we have to resolve them right now - components.annotationResolver.resolveAnnotationsWithArguments( - scope, ((KtAnnotatedExpression) leftOperand).getAnnotationEntries(), context.trace - ); + basic.resolveAnnotationsOnExpression((KtAnnotatedExpression) leftOperand, context); } KtExpression left = deparenthesize(leftOperand); KtExpression right = expression.getRight();