[groovy] do not try to infer rValue within index property assignment (EA-58298)

This commit is contained in:
Daniil Ovchinnikov
2016-03-09 19:30:31 +03:00
parent 649a1a4d51
commit f5341956f0
2 changed files with 27 additions and 2 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 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.
@@ -33,6 +33,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrReturnState
import org.jetbrains.plugins.groovy.lang.psi.api.statements.branch.GrThrowStatement;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrIndexProperty;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrGdkMethod;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
@@ -95,7 +96,13 @@ public class SubstitutorComputer {
}
}
else if (parent instanceof GrAssignmentExpression && myPlaceToInferContext.equals(((GrAssignmentExpression)parent).getRValue())) {
return ((GrAssignmentExpression)parent).getLValue().getType();
GrExpression lValue = ((GrAssignmentExpression)parent).getLValue();
if (lValue instanceof GrIndexProperty) {
return null;
}
else {
return lValue.getType();
}
}
else if (parent instanceof GrVariable) {
return ((GrVariable)parent).getDeclaredType();
@@ -1969,6 +1969,24 @@ import groovy.transform.Field
@Field
def (,<error descr="Identifier expected">)</error>
'''
}
void 'test no SOE in index property assignment with generic function'() {
testHighlighting '''
class Main {
static <T> T foo() {}
static void main(String[] args) {
def main = new Main()
main[Main] = foo()
}
def putAt(x, String t) {
println "Works: $x = $t"
}
}
'''
}
}