# Buggy code
def visit_unbound_type(self, t: UnboundType) -> Type:
    assert False, "Not supported"


# Traceback (AssertionError)
tmp.py:3: error: Invalid type "tmp.Bad"
tmp.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/issues version: 0.570-dev-d2c04190b8d407476c535f30d07a9f6712e7b12a-dirty
Traceback (most recent call last):
File "/Users/ilevkivskyi/mypy/bin/mypy", line 11, in <module>
load_entry_point('mypy===0.570-dev-d2c04190b8d407476c535f30d07a9f6712e7b12a-dirty', 'console_scripts', 'mypy')()
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/main.py", line 80, in main
type_check_only(sources, bin_dir, options, flush_errors)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/main.py", line 129, in type_check_only
flush_errors=flush_errors)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/build.py", line 172, in build
result = _build(sources, options, alt_lib_path, bin_dir, saved_cache, flush_errors)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/build.py", line 258, in _build
graph = dispatch(sources, manager)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/build.py", line 2048, in dispatch
process_graph(graph, manager)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/build.py", line 2349, in process_graph
process_stale_scc(graph, scc, manager)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/build.py", line 2525, in process_stale_scc
graph[id].type_check_first_pass()
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/build.py", line 1923, in type_check_first_pass
self.type_checker().check_first_pass()
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/checker.py", line 228, in check_first_pass
self.accept(d)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/checker.py", line 323, in accept
stmt.accept(self)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/nodes.py", line 928, in accept
return visitor.visit_if_stmt(self)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/checker.py", line 2232, in visit_if_stmt
if_map, else_map = self.find_isinstance_check(e)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/checker.py", line 2835, in find_isinstance_check
return conditional_type_map(expr, vartype, type)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/checker.py", line 3191, in conditional_type_map
remaining_type = restrict_subtype_away(current_type, proposed_precise_type)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/subtypes.py", line 817, in restrict_subtype_away
new_items = [item for item in t.relevant_items()
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/subtypes.py", line 818, in <listcomp>
if (not (is_proper_subtype(erase_type(item), erased_s) or
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/erasetype.py", line 25, in erase_type
return typ.accept(EraseTypeVisitor())
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/types.py", line 194, in accept
return visitor.visit_unbound_type(self)
File "/Users/ilevkivskyi/mypy/lib/python3.6/site-packages/mypy/erasetype.py", line 31, in visit_unbound_type
assert False, 'Not supported'
AssertionError: Not supported

# Fixed code
def visit_unbound_type(self, t: UnboundType) -> Type:
    # TODO: replace with an assert after UnboundType can't leak from semantic analysis.
    return AnyType(TypeOfAny.from_error)