mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-61591 The scope of a class' variable does not extend to contained blocks
GitOrigin-RevId: 871bb3584f9c72f91aced9e86909feccf0a901d7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
059a568ad0
commit
3affb20872
+5
-3
@@ -736,9 +736,11 @@ public final class PyExtractMethodUtil {
|
||||
myFunction = s -> {
|
||||
ScopeOwner owner = parent;
|
||||
while (owner != null) {
|
||||
final Scope scope = ControlFlowCache.getScope(owner);
|
||||
if (scope.containsDeclaration(s)) {
|
||||
return false;
|
||||
if (!(owner instanceof PyClass)) {
|
||||
final Scope scope = ControlFlowCache.getScope(owner);
|
||||
if (scope.containsDeclaration(s)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
owner = ScopeUtil.getScopeOwner(owner);
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class A:
|
||||
def foo(self): ...
|
||||
|
||||
def bar(self):
|
||||
def baz():
|
||||
foo()
|
||||
|
||||
def foo():
|
||||
print('baz')
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class A:
|
||||
def foo(self): ...
|
||||
|
||||
def bar(self):
|
||||
def baz():
|
||||
<selection>print('baz')</selection>
|
||||
@@ -391,4 +391,9 @@ public class PyExtractMethodTest extends LightMarkedTestCase {
|
||||
public void testMethodNameCanShadowModuleFunction() {
|
||||
doTest("_require_instance");
|
||||
}
|
||||
|
||||
// PY-61591
|
||||
public void testInnerFunctionWithSameNameAsOuterMethod() {
|
||||
doTest("foo");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user