Make Union/Optional works with compiled objects

This commit is contained in:
Dave Halter committed 2020-01-10 13:34:10 +01:00
1 parent ba7776c0d9
commit cac73f2d44
3 files changed
+23 -1

No files matched your search

+5
View File
@@ -271,6 +271,11 @@ class CompiledObject(Value):
if self.access_handle.get_repr() == 'None':
# None as an annotation doesn't need to be executed.
return ValueSet([self])
name, args = self.access_handle.get_annotation_name_and_args()
arguments = [create_from_access_path(self.inference_state, path) for path in args]
if name == 'typing.Union':
return ValueSet.from_sets(arg.execute_annotation() for arg in arguments)
return super(CompiledObject, self).execute_annotation()
def negate(self):