public function alias($name, $spec)
    {
        if (is_callable($spec)) {
            $this->instances[$name] = $spec;
        } else {
            $this->aliases[$name] = $spec;

            // Ensure that the new alias will be used when called.
            unset($this->instances[$name]);
        }
    }