def _populate_union_type_attributes(self, env, data_type):
parent_type = None<EOL>extends = data_type._ast_node.extends<EOL>if extends:<EOL><INDENT>parent_type = self._resolve_type(env, extends, True)<EOL>if isinstance(parent_type, Alias):<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>',<EOL>data_type._ast_node.lineno, data_type._ast_node.path)<EOL><DEDENT>if isinstance(parent_type, Nullable):<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>',<EOL>data_type._ast_node.lineno, data_type._ast_node.path)<EOL><DEDENT>if not isinstance(parent_type, Union):<EOL><INDENT>raise InvalidSpec(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>' % quote(parent_type.name),<EOL>data_type._ast_node.lineno, data_type._ast_node.path)<EOL><DEDENT><DEDENT>api_type_fields = []<EOL>for stone_field in data_type._ast_node.fields:<EOL><INDENT>if stone_field.name == '<STR_LIT>':<EOL><INDENT>raise InvalidSpec(<EOL>"<STR_LIT>"<EOL>"<STR_LIT>",<EOL>stone_field.lineno, stone_field.path)<EOL><DEDENT>api_type_fields.append(self._create_union_field(env, stone_field))<EOL><DEDENT>catch_all_field = None<EOL>if data_type.closed:<EOL><INDENT>if parent_type and not parent_type.closed:<EOL><INDENT>raise InvalidSpec(<EOL>"<STR_LIT>" % (<EOL>parent_type.name),<EOL>data_type._ast_node.lineno, data_type._ast_node.path)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if not parent_type or parent_type.closed:<EOL><INDENT>catch_all_field = UnionField(<EOL>name='<STR_LIT>', data_type=Void(), doc=None,<EOL>ast_node=data_type._ast_node, catch_all=True)<EOL>api_type_fields.append(catch_all_field)<EOL><DEDENT><DEDENT>data_type.set_attributes(<EOL>data_type._ast_node.doc, api_type_fields, parent_type, catch_all_field)<EOL>
Converts a forward reference of a union into a complete definition.