<commit_before>package polyglot.ext.jl5.types;

import java.util.Collections;

import polyglot.types.ArrayType_c;
import polyglot.types.MethodInstance;
import polyglot.types.Type;
import polyglot.types.TypeSystem;
import polyglot.util.Position;

@SuppressWarnings("serial")
public class JL5ArrayType_c extends ArrayType_c implements JL5ArrayType {

    protected boolean isVarArg;

    public JL5ArrayType_c(TypeSystem ts, Position pos, Type base, boolean isVarargs){
        super(ts, pos, base);
        this.isVarArg = isVarargs;
    }
    
    @Override
    protected MethodInstance createCloneMethodInstance() {
        return ts.methodInstance(position(),
                this,
                ts.Public(),
                this, // clone returns this type
                "clone",
                Collections.EMPTY_LIST,
                Collections.EMPTY_LIST);
    }

    @Override
    public boolean isVarArg(){
        return this.isVarArg;
    }
    
    @Override
    public void setVarArg() {
    	this.isVarArg = true;
    }

}
<commit_msg>Added subtyping rule for arrays: A[] < B[] if A < B.<commit_after>package polyglot.ext.jl5.types;

import java.util.Collections;

import polyglot.types.ArrayType;
import polyglot.types.ArrayType_c;
import polyglot.types.MethodInstance;
import polyglot.types.Type;
import polyglot.types.TypeSystem;
import polyglot.util.Position;

@SuppressWarnings("serial")
public class JL5ArrayType_c extends ArrayType_c implements JL5ArrayType {

    protected boolean isVarArg;

    public JL5ArrayType_c(TypeSystem ts, Position pos, Type base, boolean isVarargs){
        super(ts, pos, base);
        this.isVarArg = isVarargs;
    }
    
    @Override
    protected MethodInstance createCloneMethodInstance() {
        return ts.methodInstance(position(),
                this,
                ts.Public(),
                this, // clone returns this type
                "clone",
                Collections.EMPTY_LIST,
                Collections.EMPTY_LIST);
    }

    @Override
    public boolean isVarArg(){
        return this.isVarArg;
    }
    
    @Override
    public void setVarArg() {
    	this.isVarArg = true;
    }

    @Override
    public boolean isSubtypeImpl(Type t) {
        if (super.isSubtypeImpl(t)) {
            return true;
        }
        
        /* See JLS 3rd Ed 4.10 */
        if (t instanceof ArrayType) {
            ArrayType at = (ArrayType)t;
            return this.base().isSubtype(at.base());
        }
        
        return false;
    }
    

}

{'fraction_non_alphanumeric': 0.08911671924290221, 'fraction_numerical': 0.00473186119873817, 'mean_word_length': 2.2609254498714653, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3512666', 'n_tokens_mistral': 760, 'n_tokens_neox': 745, 'n_words': 170}