<commit_before>/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003, LAMP/EPFL                  **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$

package scala.runtime.types;

import scala.Type;
import scala.Array;
import scala.ScalaObject;
import scala.runtime.RunTime;

/**
 * Run-time representation for compound types.
 *
 * @author <NAME>
 * @version 1.0
 */

public class CompoundType extends Type {
    public final ClassType[] components;

    public CompoundType(ClassType[] components, boolean emptyRefinement) {
        this.components = components;

        if (!emptyRefinement)
            throw new Error("attempt to build a compound type with "
                            + "non-empty refinement");
    }

    public Array newArray(int size) {
        throw new Error();      // TODO
    }

    public Object defaultValue() {
        return null;
    }

    public boolean isInstance(Object o) {
        assert Statistics.incInstanceOf();
        for (int i = 0; i < components.length; ++i) {
            if (!components[i].isInstance(o))
                return false;
        }

        return true;
    }

    public boolean isSubType(Type that) {
        if (that instanceof CompoundType) {
            ClassType[] thatComponents = ((CompoundType)that).components;
            for (int i = 0; i < thatComponents.length; ++i) {
                if (!this.isSubType(thatComponents[i]))
                    return false;
            }
            return true;
        } else {
            for (int i = 0; i < components.length; ++i) {
                if (components[i].isSubType(that))
                    return true;
            }
            return false;
        }
    }

    public boolean isSameType(Type that) {<commit_msg>- accept the creation of compound types with no...<commit_after>/*                     __                                               *\
**     ________ ___   / /  ___     Scala API                            **
**    / __/ __// _ | / /  / _ |    (c) 2003, LAMP/EPFL                  **
**  __\ \/ /__/ __ |/ /__/ __ |                                         **
** /____/\___/_/ |_/____/_/ | |                                         **
**                          |/                                          **
\*                                                                      */

// $Id$

package scala.runtime.types;

import scala.Type;
import scala.Array;
import scala.ScalaObject;
import scala.runtime.RunTime;

/**
 * Run-time representation for compound types.
 *
 * @author <NAME>
 * @version 1.0
 */

public class CompoundType extends Type {
    public final ClassType[] components;
    public final boolean emptyRefinement;

    public CompoundType(ClassType[] components, boolean emptyRefinement) {
        this.components = components;
        this.emptyRefinement = emptyRefinement;
    }

    public Array newArray(int size) {
        throw new Error();      // TODO
    }

    public Object defaultValue() {
        return null;
    }

    public boolean isInstance(Object o) {
        assert Statistics.incInstanceOf();
        for (int i = 0; i < components.length; ++i) {
            if (!components[i].isInstance(o))
                return false;
        }

        return true;
    }

    public boolean isSubType(Type that) {
        if (!emptyRefinement)
            throw new Error("cannot compute isSubType (non-empty refinement)");

        if (that instanceof CompoundType) {
            CompoundType thatCT = (CompoundType)that;
            ClassType[] thatComponents = thatCT.components;
            for (int i = 0; i < thatComponents.length; ++i) {
                if (!this.isSubType(thatComponents[i]))
                    return false;
            }
            return true;
        } else {
            for (int i = 0; i < components.length; ++i) {
                if (components[i].isSubType(that))
                    return true;
            }
            return false;
        }
    }

    public boolean isSameType(Type that) {
        if (!emptyRefinement)
            throw new Error("cannot compute isSameType (non-empty refinement)");

{'fraction_non_alphanumeric': 0.10672546857772877, 'fraction_numerical': 0.003969128996692392, 'mean_word_length': 1.2300884955752212, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '925107', 'n_tokens_mistral': 1179, 'n_tokens_neox': 1115, 'n_words': 280}