mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
If reference points to property and property type could not be inferred, stop with "Any", don't do any further processing.
This commit is contained in:
@@ -238,9 +238,9 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
}
|
||||
|
||||
if (qualified) {
|
||||
final PyType qualifiedReferenceType = getQualifiedReferenceType(context);
|
||||
final Ref<PyType> qualifiedReferenceType = getQualifiedReferenceType(context);
|
||||
if (qualifiedReferenceType != null) {
|
||||
return qualifiedReferenceType;
|
||||
return qualifiedReferenceType.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,22 +256,22 @@ public class PyReferenceExpressionImpl extends PyElementImpl implements PyRefere
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PyType getQualifiedReferenceType(@NotNull TypeEvalContext context) {
|
||||
private Ref<PyType> getQualifiedReferenceType(@NotNull TypeEvalContext context) {
|
||||
if (!context.maySwitchToAST(this)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final PyType maybe_type = PyUtil.getSpecialAttributeType(this, context);
|
||||
if (maybe_type != null) return maybe_type;
|
||||
if (maybe_type != null) return Ref.create(maybe_type);
|
||||
|
||||
final Ref<PyType> typeOfProperty = getTypeOfProperty(context);
|
||||
if (typeOfProperty != null) {
|
||||
return typeOfProperty.get();
|
||||
return typeOfProperty;
|
||||
}
|
||||
|
||||
final PyType typeByControlFlow = getQualifiedReferenceTypeByControlFlow(context);
|
||||
if (typeByControlFlow != null) {
|
||||
return typeByControlFlow;
|
||||
return Ref.create(typeByControlFlow);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
def get_class():
|
||||
return str
|
||||
@@ -1665,6 +1665,17 @@ public class PyTypeTest extends PyTestCase {
|
||||
" print(expr)");
|
||||
}
|
||||
|
||||
public void testImportedPropertyResult() {
|
||||
doMultiFileTest("Any",
|
||||
"from .temporary import get_class\n" +
|
||||
"class Example:\n" +
|
||||
" def __init__(self):\n" +
|
||||
" expr = self.ins_class\n" +
|
||||
" @property\n" +
|
||||
" def ins_class(self):\n" +
|
||||
" return get_class()");
|
||||
}
|
||||
|
||||
private static List<TypeEvalContext> getTypeEvalContexts(@NotNull PyExpression element) {
|
||||
return ImmutableList.of(TypeEvalContext.codeAnalysis(element.getProject(), element.getContainingFile()).withTracing(),
|
||||
TypeEvalContext.userInitiated(element.getProject(), element.getContainingFile()).withTracing());
|
||||
|
||||
Reference in New Issue
Block a user