[groovy] follow up IDEA-CR-17601

This commit is contained in:
Daniil Ovchinnikov
2017-01-25 15:23:28 +03:00
parent a00eaaffc9
commit 9893ab3fab
3 changed files with 11 additions and 16 deletions
@@ -52,9 +52,5 @@ public interface GrReferenceExpression extends GrExpression, GrReferenceElement<
GrReferenceExpression bindToElementViaStaticImport(@NotNull PsiMember member);
@Nullable
@Override
default PsiType getType() { return getType(false); }
@Nullable
PsiType getType(boolean forceRValue);
PsiType getRValueType();
}
@@ -189,7 +189,7 @@ public class GrAssignmentExpressionImpl extends GrOperatorExpressionImpl impleme
lType = ((GrIndexProperty)lValue).getGetterType();
}
else if (lValue instanceof GrReferenceExpression) {
lType = ((GrReferenceExpression)lValue).getType(true);
lType = ((GrReferenceExpression)lValue).getRValueType();
}
else {
lType = lValue.getType();
@@ -368,7 +368,7 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
}
@Nullable
private static PsiType calculate(@NotNull GrReferenceExpressionImpl refExpr, boolean forceRValue) {
private static PsiType calculateType(@NotNull GrReferenceExpressionImpl refExpr, boolean forceRValue) {
final GroovyResolveResult[] results = refExpr.multiResolve(false, forceRValue);
final GroovyResolveResult result = PsiImplUtil.extractUniqueResult(results);
final PsiElement resolved = result.getElement();
@@ -455,15 +455,14 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
@Nullable
@Override
public PsiType getType(boolean forceRValue) {
if (forceRValue) {
return calculate(this, true);
}
else {
return TypeInferenceHelper.getCurrentContext().getExpressionType(
this, e -> calculate(e, false)
);
}
public PsiType getType() {
return TypeInferenceHelper.getCurrentContext().getExpressionType(this, e -> calculateType(e, false));
}
@Nullable
@Override
public PsiType getRValueType() {
return calculateType(this, true);
}
@Override