diff --git a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GrReferenceResolveRunner.kt b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GrReferenceResolveRunner.kt index d17d85bfcef0..d1ab69ecfd67 100644 --- a/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GrReferenceResolveRunner.kt +++ b/plugins/groovy/groovy-psi/src/org/jetbrains/plugins/groovy/lang/resolve/GrReferenceResolveRunner.kt @@ -166,21 +166,20 @@ private fun GrReferenceExpression.doResolveStatic(): GroovyResolveResult? { } } - if (qualifier == null || qualifier.isThisExpression()) { - val field = resolveToField(name).singleOrNull() - if (field != null && checkCurrentClass(field.element, this)) { - return field - } - } - if (parent !is GrMethodCall) { + if (qualifier == null || qualifier.isThisExpression()) { + val field = resolveToField(name).singleOrNull() + if (field != null && checkCurrentClass(field.element, this)) { + return field + } + } if (qualifier == null) { // at this point: // - the reference is org.codehaus.groovy.ast.expr.VariableExpression // - the reference doesn't resolve to a variable, meaning it accesses org.codehaus.groovy.ast.DynamicVariable return resolveUnqualifiedType(name) } - else if (qualifier is GrReferenceExpression) { + if (qualifier is GrReferenceExpression) { return resolveQualifiedType(name, qualifier) } } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy index eedd13e2624a..d0cdf9440bb5 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/resolve/ResolvePropertyTest.groovy @@ -1516,4 +1516,14 @@ println A.name ''', PsiMethod assert property.containingClass.qualifiedName == 'java.lang.Class' } + + void "test don't resolve to field in method call"() { + resolveByText '''\ +class Fff { + List testThis = [""] + def usage() { testThis(1) } + def testThis(a) {} +} +''', GrMethod + } }