[groovy] operator assignment: do not cache forced rValue type

This commit is contained in:
Daniil Ovchinnikov
2017-01-23 13:26:57 +03:00
parent 04b1b9be49
commit fe31bbdf72
2 changed files with 4 additions and 38 deletions
@@ -1,30 +0,0 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions
import com.intellij.psi.impl.light.LightElement
import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor
import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement
class GrFakeReferenceExpressionElement(val original: GrReferenceExpressionImpl)
: LightElement(original.manager, original.language), GroovyPsiElement {
override fun accept(visitor: GroovyElementVisitor?) = Unit
override fun acceptChildren(visitor: GroovyElementVisitor?) = Unit
override fun toString() = "fake reference expression element"
}
@@ -78,10 +78,6 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
() -> new GrReferenceExpressionReference(this, true)
);
private final NotNullLazyValue<GrFakeReferenceExpressionElement> myFakeGetterElement = AtomicNotNullLazyValue.createValue(
() -> new GrFakeReferenceExpressionElement(this)
);
private final NotNullLazyValue<GrReferenceExpressionReference> myFakeReference = AtomicNotNullLazyValue.createValue(
() -> new GrReferenceExpressionReference(this, false)
);
@@ -372,7 +368,8 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
return null;
}
private static PsiType calculate(GrReferenceExpressionImpl refExpr, boolean forceRValue) {
@Nullable
private static PsiType calculate(@NotNull GrReferenceExpressionImpl refExpr, boolean forceRValue) {
final GroovyResolveResult[] results = refExpr.multiResolve(false, forceRValue);
final GroovyResolveResult result = PsiImplUtil.extractUniqueResult(results);
final PsiElement resolved = result.getElement();
@@ -457,12 +454,11 @@ public class GrReferenceExpressionImpl extends GrReferenceElementImpl<GrExpressi
return null;
}
@Nullable
@Override
public PsiType getType(boolean forceRValue) {
if (forceRValue) {
return TypeInferenceHelper.getCurrentContext().getExpressionType(
myFakeGetterElement.getValue(), e -> calculate(e.getOriginal(), true)
);
return calculate(this, true);
}
else {
return TypeInferenceHelper.getCurrentContext().getExpressionType(