protected function generate(string $abstract, ReflectionParameter $dependency) : Closure
    {
        if ($class = $dependency->getClass()) {
            return $this->build($class->name, "{$abstract}{$class->name}");
        }

        try {
            $value = $dependency->getDefaultValue();

            return function () use ($value) {
                return $value;
            };
        } catch (ReflectionException $e) {
            throw new ContainerException("Cannot resolve '$dependency->name' of '$abstract'", 0, $e);
        }
    }