Closed
Description
We got the same exception as #4370 (though with a somewhat different traceback). The user sent me a repro (which I have not managed to confirm):
class BaseClass(object):
def some_method(self):
# type: () -> BaseClass
pass
class SubClass1(BaseClass):
def some_method(self):
# type: () -> AnotherNameForSubClass1 # <--- Forward ref to alias causes crash
pass
AnotherNameForSubClass1 = SubClass1
The traceback ended in:
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checker.py", line 2101, in visit_return_stmt
self.check_return_stmt(s)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checker.py", line 2132, in check_return_stmt
allow_none_return=allow_none_func_call)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checkexpr.py", line 2365, in accept
typ = node.accept(self)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/nodes.py", line 1245, in accept
return visitor.visit_call_expr(self)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checkexpr.py", line 268, in visit_call_expr
ret_type = self.check_call_expr_with_callee_type(callee_type, e, fullname, object_type)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checkexpr.py", line 505, in check_call_expr_with_callee_type
object_type=object_type)[0]
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checkexpr.py", line 578, in check_call
messages=arg_messages)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checkexpr.py", line 1048, in check_argument_types
actual + 1, i + 1, callee, context, messages)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/checkexpr.py", line 1080, in check_arg
elif not is_subtype(caller_type, callee_type):
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/subtypes.py", line 83, in is_subtype
ignore_declared_variance=ignore_declared_variance))
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/types.py", line 1415, in accept
return visitor.visit_forwardref_type(self)
File "/Users/xxx/src/server/.mypy/venv/lib/python3.5/site-packages/mypy/types.py", line 1500, in visit_forwardref_type
raise RuntimeError('Internal error: unresolved forward reference')
RuntimeError: Internal error: unresolved forward reference
However there must be something else because the test program does not repro the crash.