<commit_before>package org.rust.lang.core.types.visitors.impl

import org.rust.lang.core.types.*
import org.rust.lang.core.types.unresolved.*
import org.rust.lang.core.types.visitors.RustInvariantTypeVisitor
import org.rust.lang.core.types.visitors.RustTypeVisitor
import org.rust.lang.core.types.visitors.RustUnresolvedTypeVisitor
import org.rust.utils.safely

open class RustEqualityTypeVisitor(override var lop: RustType)
    : RustEqualityTypeVisitorBase<RustType>()
    , RustTypeVisitor<Boolean> {

    protected fun visit(lop: RustType, rop: RustType): Boolean {
        val prev = this.lop
        this.lop = lop

        return safely({ rop.accept(this) }) {
            this.lop = prev
        }
    }

    protected fun visitTypeList(lop: Iterable<RustType>, rop: Iterable<RustType>): Boolean =
        lop.zip(rop).fold(true, { r, p -> r && visit(p.first, p.second) })

    override fun visitStruct(type: RustStructType): Boolean {
        val lop = lop
        if (lop !is RustStructType)
            return false

        return lop.struct == type.struct
    }

    override fun visitEnum(type: RustEnumType): Boolean {
        val lop = lop
        if (lop !is RustEnumType)
            return false

        return lop.enum == type.enum
    }

    override fun visitTupleType(type: RustTupleType): Boolean {
        val lop = lop
        if (lop !is RustTupleType || lop.size != type.size)
            return false

        return visitTypeList(lop.types, type.types)
    }

    override fun visitFunctionType(type: RustFunctionType): Boolean {
        val lop = lop
        if (lop !is RustFunctionType)
            return false

        return visit(lop.retType, type.retType) && visitTypeList(lop.paramTypes, type.paramTypes)
    }

    override fun visitTypeParameter(type: RustTypeParameterType): Boolean {
        val lop = lop
        if (lop !is RustTypeParameterType)
            return false

        return lop.parameter === type.parameter
    }

    override fun visitReference(type: RustReferenceType): Boolean {
        val lop = lop
        if (lop !is RustReferenceType)
            return false

        return lop.mutable == type.mutable && visit(lop.referenced, type.referenced)
    }
}


open class RustEqualityUnresolvedTypeVisitor(override var lop: RustUnresolvedType)
    : RustEqualityTypeVisitorBase<RustUnresolvedType>()
    , RustUnresolvedTypeVisitor<Boolean> {

    fun visit(lop: RustUnresolvedType, rop: RustUnresolvedType): Boolean {
        val prev = this.lop
        this.lop = lop

        return safely({ rop.accept(this) }) {
            this.lop = prev
        }
    }

    fun visitTypeList(lop: Iterable<RustUnresolvedType>, rop: Iterable<RustUnresolvedType>): Boolean =
        lop.zip(rop).fold(true, { r, p -> r && visit(p.first, p.second) })

    override fun visitPathType(type: RustUnresolvedPathType): Boolean {
        val lop = lop
        if (lop !is RustUnresolvedPathType)
            return false

        return lop.path == type.path
    }

    override fun visitTupleType(type: RustUnresolvedTupleType): Boolean {
        val lop = lop
        if (lop !is RustUnresolvedTupleType)
            return false

        return visitTypeList(lop.types, type.types)
    }

    override fun visitFunctionType(type: RustUnresolvedFunctionType): Boolean {
        val lop = lop
        if (lop !is RustUnresolvedFunctionType)
            return false

        return visit(lop.retType, type.retType) && visitTypeList(lop.paramTypes, type.paramTypes)
    }

    override fun visitReference(type: RustUnresolvedReferenceType): Boolean {
        val lop = lop<commit_msg>(TYP): Fixed `RustTypeEqualityVisitor`<commit_after>package org.rust.lang.core.types.visitors.impl

import org.rust.lang.core.types.*
import org.rust.lang.core.types.unresolved.*
import org.rust.lang.core.types.visitors.RustInvariantTypeVisitor
import org.rust.lang.core.types.visitors.RustTypeVisitor
import org.rust.lang.core.types.visitors.RustUnresolvedTypeVisitor
import org.rust.utils.safely

open class RustEqualityTypeVisitor(override var lop: RustType)
    : RustEqualityTypeVisitorBase<RustType>()
    , RustTypeVisitor<Boolean> {

    protected fun visit(lop: RustType, rop: RustType): Boolean {
        val prev = this.lop
        this.lop = lop

        return safely({ rop.accept(this) }) {
            this.lop = prev
        }
    }

    protected fun visitTypeList(lop: Iterable<RustType>, rop: Iterable<RustType>): Boolean =
        lop.zip(rop).fold(true, { r, p -> r && visit(p.first, p.second) })

    override fun visitStruct(type: RustStructType): Boolean {
        val lop = lop
        if (lop !is RustStructType)
            return false

        return lop.struct == type.struct
    }

    override fun visitEnum(type: RustEnumType): Boolean {
        val lop = lop
        if (lop !is RustEnumType)
            return false

        return lop.enum == type.enum
    }

    override fun visitTupleType(type: RustTupleType): Boolean {
        val lop = lop
        if (lop !is RustTupleType || lop.size != type.size)
            return false

        return visitTypeList(lop.types, type.types)
    }

    override fun visitFunctionType(type: RustFunctionType): Boolean {
        val lop = lop
        if (lop !is RustFunctionType)
            return false

        return visit(lop.retType, type.retType) && visitTypeList(lop.paramTypes, type.paramTypes)
    }

    override fun visitTypeParameter(type: RustTypeParameterType): Boolean {
        val lop = lop
        if (lop !is RustTypeParameterType)
            return false

        return lop.parameter === type.parameter
    }

    override fun visitReference(type: RustReferenceType): Boolean {
        val lop = lop
        if (lop !is RustReferenceType)
            return false

        return lop.mutable == type.mutable && visit(lop.referenced, type.referenced)
    }
}


open class RustEqualityUnresolvedTypeVisitor(override var lop: RustUnresolvedType)
    : RustEqualityTypeVisitorBase<RustUnresolvedType>()
    , RustUnresolvedTypeVisitor<Boolean> {

    fun visit(lop: RustUnresolvedType, rop: RustUnresolvedType): Boolean {
        val prev = this.lop
        this.lop = lop

        return safely({ rop.accept(this) }) {
            this.lop = prev
        }
    }

    fun visitTypeList(lop: Iterable<RustUnresolvedType>, rop: Iterable<RustUnresolvedType>): Boolean =
        lop.count() == rop.count() && lop.zip(rop).fold(true, { r, p -> r && visit(p.first, p.second) })

    override fun visitPathType(type: RustUnresolvedPathType): Boolean {
        val lop = lop
        if (lop !is RustUnresolvedPathType)
            return false

        return lop.path == type.path
    }

    override fun visitTupleType(type: RustUnresolvedTupleType): Boolean {
        val lop = lop
        if (lop !is RustUnresolvedTupleType)
            return false

        return visitTypeList(lop.types, type.types)
    }

    override fun visitFunctionType(type: RustUnresolvedFunctionType): Boolean {
        val lop = lop
        if (lop !is RustUnresolvedFunctionType)
            return false

        return visit(lop.retType, type.retType) && visitTypeList(lop.paramTypes, type.paramTypes)
    }

    override fun visitReference(type: RustUnresolvedReferenceType): Boolean {
        val lop = lop
{'fraction_non_alphanumeric': 0.09446343130553657, 'fraction_numerical': 0.0, 'mean_word_length': 2.674535409342039, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, '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': '1467534', 'n_tokens_mistral': 2291, 'n_tokens_neox': 2123, 'n_words': 517}