class ScopeState {
        private final Map<Key<?>, Provider<?>> seeded = new HashMap<>();

        private final Map<Key<?>, Object> provided = new HashMap<>();
    }

    private final ThreadLocal<LinkedList<ScopeState>> values = new ThreadLocal<>();

    public MojoExecutionScope() {}

    public void enter() {
        LinkedList<ScopeState> stack = values.get();
        if (stack == null) {
            stack = new LinkedList<>();
            values.set(stack);
        }
        stack.addFirst(new ScopeState());
    }

    private ScopeState getScopeState() {
        LinkedList<ScopeState> stack = values.get();
        if (stack == null || stack.isEmpty()) {
            throw new IllegalStateException();
        }
        return stack.getFirst();
    }

    public void exit() throws MojoExecutionException {
        final LinkedList<ScopeState> stack = values.get();
        if (stack == null || stack.isEmpty()) {
            throw new IllegalStateException();
        }
        stack.removeFirst();
        if (stack.isEmpty()) {
            values.remove();
        }
    }

    public <T> void seed(Class<T> clazz, Provider<T> value) {
        getScopeState().seeded.put(Key.get(clazz), value);
    }

    public <T> void seed(Class<T> clazz, final T value) {
        getScopeState().seeded.put(Key.get(clazz), Providers.of(value));
    }

    public <T> Provider<T> scope(final Key<T> key, final Provider<T> unscoped) {<FILL_FUNCTION_BODY>

        return () -> {
            LinkedList<ScopeState> stack = values.get();
            if (stack == null || stack.isEmpty()) {
                throw new OutOfScopeException("Cannot access " + key + " outside of a scoping block");
            }

            ScopeState state = stack.getFirst();

            Provider<?> seeded = state.seeded.get(key);

            if (seeded != null) {
                return (T) seeded.get();
            }

            T provided = (T) state.provided.get(key);
            if (provided == null && unscoped != null) {
                provided = unscoped.get();
                state.provided.put(key, provided);
            }

            return provided;
        };
    
<no_super_class>