Prevent recursion while resolving references (PY-26006)

This commit is contained in:
Semyon Proshev
2017-10-31 17:33:54 +03:00
parent 0a00f1a896
commit 9287028517
3 changed files with 23 additions and 16 deletions
@@ -98,7 +98,7 @@ public class PyReferenceImpl implements PsiReferenceEx, PsiPolyVariantReference
public ResolveResult[] multiResolve(final boolean incompleteCode) {
if (USE_CACHE) {
final ResolveCache cache = ResolveCache.getInstance(getElement().getProject());
return cache.resolveWithCaching(this, CachingResolver.INSTANCE, false, incompleteCode);
return cache.resolveWithCaching(this, CachingResolver.INSTANCE, true, incompleteCode);
}
else {
return multiResolveInner();
@@ -0,0 +1,15 @@
def foo(baz=None):
def _foo(func):
def wrapper(*args, **kwargs):
func(*args, **kwargs)
wrapper.baz = baz
return wrapper
return _foo
@foo
# <ref>
def foo():
pass
@@ -1,18 +1,4 @@
/*
* 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.
*/
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
package com.jetbrains.python;
import com.intellij.psi.PsiElement;
@@ -1246,4 +1232,10 @@ public class PyResolveTest extends PyResolveTestCase {
assertEquals("__lt__", dunderLt.getName());
assertEquals("str", dunderLt.getContainingClass().getName());
}
// PY-26006
public void testSOEDecoratingFunctionWithSameNameDecorator() {
final PyFunction function = assertInstanceOf(doResolve(), PyFunction.class);
assertEquals(4, function.getTextOffset());
}
}