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) { public KotlinTypeInfo visitAnnotatedExpression(KtAnnotatedExpression expression, ExpressionTypingContext context, boolean isStatement) {
if (!(expression.getBaseExpression() instanceof KtObjectLiteralExpression)) { resolveAnnotationsOnExpression(expression, context);
// annotations on object literals are resolved later inside LazyClassDescriptor
components.annotationResolver.resolveAnnotationsWithArguments(context.scope, expression.getAnnotationEntries(), context.trace);
}
KtExpression baseExpression = expression.getBaseExpression(); KtExpression baseExpression = expression.getBaseExpression();
if (baseExpression == null) { if (baseExpression == null) {
@@ -1541,6 +1538,13 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
return facade.getTypeInfo(baseExpression, context, isStatement); 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 @Override
public KotlinTypeInfo visitKtElement(@NotNull KtElement element, ExpressionTypingContext context) { public KotlinTypeInfo visitKtElement(@NotNull KtElement element, ExpressionTypingContext context) {
context.trace.report(UNSUPPORTED.on(element, getClass().getCanonicalName())); 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); contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE).replaceScope(scope).replaceContextDependency(INDEPENDENT);
KtExpression leftOperand = expression.getLeft(); KtExpression leftOperand = expression.getLeft();
if (leftOperand instanceof KtAnnotatedExpression) { if (leftOperand instanceof KtAnnotatedExpression) {
// We will lose all annotations during deparenthesizing, so we have to resolve them right now basic.resolveAnnotationsOnExpression((KtAnnotatedExpression) leftOperand, context);
components.annotationResolver.resolveAnnotationsWithArguments(
scope, ((KtAnnotatedExpression) leftOperand).getAnnotationEntries(), context.trace
);
} }
KtExpression left = deparenthesize(leftOperand); KtExpression left = deparenthesize(leftOperand);
KtExpression right = expression.getRight(); KtExpression right = expression.getRight();