<commit_before>package io.bootique;

import com.google.inject.Module;

class RuntimeModule {

    private BQModule bqModule;
    private RuntimeModule overriddenBy;
    private boolean overridesOthers;

    RuntimeModule(BQModule bqModule) {
        this.bqModule = bqModule;
    }

    @Override
    public boolean equals(Object object) {

        if (object == this) {
            return true;
        }

        if (object instanceof RuntimeModule) {

            RuntimeModule otherRuntimeModule = (RuntimeModule) object;

            // equality by module type...
            return getModule().getClass().equals(otherRuntimeModule.getModule().getClass());
        }

        return false;
    }

    @Override
    public int hashCode() {
        return 37 + getModule().getClass().hashCode();
    }

    public Module getModule() {
        return bqModule.getModule();
    }

    public BQModule getBqModule() {
        return bqModule;
    }

    public RuntimeModule getOverriddenBy() {
        return overriddenBy;
    }

    void checkCycles() {
        if(overriddenBy != null) {
            overriddenBy.checkCycles(this);
        }
    }

    private void checkCycles(RuntimeModule root) {
        if (root == this) {
            // TODO: show all modules participating in the detected cycle...
            throw new BootiqueException(1,
                    "Circular override dependency between DI modules. Culprit: " + getModuleName());
        }

        if(overriddenBy != null) {
            overriddenBy.checkCycles(root);<commit_msg>Can't access grandparent service in a two-level override  #157<commit_after>package io.bootique;

import com.google.inject.Module;

class RuntimeModule {

    private BQModule bqModule;
    private RuntimeModule overriddenBy;
    private boolean overridesOthers;

    RuntimeModule(BQModule bqModule) {
        this.bqModule = bqModule;
    }

    public Module getModule() {
        return bqModule.getModule();
    }

    public BQModule getBqModule() {
        return bqModule;
    }

    public RuntimeModule getOverriddenBy() {
        return overriddenBy;
    }

    void checkCycles() {
        if(overriddenBy != null) {
            overriddenBy.checkCycles(this);
        }
    }

    private void checkCycles(RuntimeModule root) {
        if (root == this) {
            // TODO: show all modules participating in the detected cycle...
            throw new BootiqueException(1,
                    "Circular override dependency between DI modules. Culprit: " + getModuleName());
        }

        if(overriddenBy != null) {
            overriddenBy.checkCycles(root);
{'fraction_non_alphanumeric': 0.0885258358662614, 'fraction_numerical': 0.0026595744680851063, 'mean_word_length': 2.2188264058679708, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2555182', 'n_tokens_mistral': 750, 'n_tokens_neox': 708, 'n_words': 178}