Minor. Extract method for annotations resolution on expression

This commit is contained in:
Denis Zharkov
2016-10-07 14:44:24 +03:00
parent bec84b1d7b
commit 993d226c8f
2 changed files with 9 additions and 8 deletions
@@ -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()));
@@ -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();