# Buggy code
def deserialize(cls, data: JsonDict) -> "OverloadedFuncDef":
    assert data[".class"] == "OverloadedFuncDef"
    res = OverloadedFuncDef(
        [cast(OverloadPart, SymbolNode.deserialize(d)) for d in data["items"]]
    )
    if data.get("impl") is not None:
        res.impl = cast(OverloadPart, SymbolNode.deserialize(data["impl"]))
    if data.get("type") is not None:
        res.type = mypy.types.deserialize_type(data["type"])
    res._fullname = data["fullname"]
    set_flags(res, data["flags"])
    # NOTE: res.info will be set in the fixup phase.
    return res


# Traceback (AssertionError)
Traceback (most recent call last):
File "/home/andrew/.virtualenvs/platform-api-clients/bin/mypy", line 11, in <module>
sys.exit(console_entry())
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/__main__.py", line 7, in console_entry
main(None)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/main.py", line 92, in main
res = build.build(sources, options, None, flush_errors, fscache)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/build.py", line 156, in build
result = _build(sources, options, alt_lib_path, flush_errors, fscache)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/build.py", line 206, in _build
graph = dispatch(sources, manager)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/build.py", line 2232, in dispatch
process_graph(graph, manager)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/build.py", line 2525, in process_graph
process_fresh_modules(graph, prev_scc, manager)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/build.py", line 2609, in process_fresh_modules
graph[id].load_tree()
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/build.py", line 1604, in load_tree
self.tree = MypyFile.deserialize(data)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/nodes.py", line 277, in deserialize
tree.names = SymbolTable.deserialize(data['names'])
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/nodes.py", line 2864, in deserialize
st[key] = SymbolTableNode.deserialize(value)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/nodes.py", line 2812, in deserialize
node = SymbolNode.deserialize(data['node'])
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/nodes.py", line 200, in deserialize
return method(data)
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/nodes.py", line 478, in deserialize
for d in data['items']])
File "/home/andrew/.virtualenvs/platform-api-clients/lib/python3.6/site-packages/mypy/nodes.py", line 446, in __init__
assert len(items) > 0
AssertionError

# Fixed code
def deserialize(cls, data: JsonDict) -> "OverloadedFuncDef":
    assert data[".class"] == "OverloadedFuncDef"
    res = OverloadedFuncDef(
        [cast(OverloadPart, SymbolNode.deserialize(d)) for d in data["items"]]
    )
    if data.get("impl") is not None:
        res.impl = cast(OverloadPart, SymbolNode.deserialize(data["impl"]))
        # set line for empty overload items, as not set in __init__
        if len(res.items) > 0:
            res.set_line(res.impl.line)
    if data.get("type") is not None:
        res.type = mypy.types.deserialize_type(data["type"])
    res._fullname = data["fullname"]
    set_flags(res, data["flags"])
    # NOTE: res.info will be set in the fixup phase.
    return res