<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def link(self):
 """Resolve and link all types in the scope."""


        type_specs = {}
        types = []

        for name, type_spec in self.scope.type_specs.items():
            type_spec = type_spec.link(self.scope)
            type_specs[name] = type_spec

            if type_spec.surface is not None:
                self.scope.add_surface(name, type_spec.surface)
                types.append(type_spec.surface)

        self.scope.type_specs = type_specs
        self.scope.add_surface('__types__', tuple(types))