<commit_before>package ch.usi.inf.l3.sana.ooj.types


import ch.usi.inf.l3.sana
import sana.primj
import sana.tiny
import sana.calcj
import sana.ooj
import tiny.symbols.Symbol
import tiny.names.Name
import tiny.types.Type
import calcj.types.PrimitiveType
import ooj.names.StdNames._

import scala.collection.immutable.Set


trait RefType extends Type {
  def name: Name
}


trait ClassTypeApi extends RefType {
  def qual: String
  def parents: Set[Symbol]

  def qualifiedName: String = s"$qual.${name.asString}"
  def allParents: Set[Type] = parents.flatMap { parent =>
    parent.tpe match {
      case Some(ctpe: ClassTypeApi)  => ctpe.allParents
      case _                         => Set.empty[Type]
    }
  }

  def =:=(t: Type): Boolean = t match {
    case ct: ClassTypeApi   =>
      lazy val res = this.allParents.foldLeft(true)((z, y) => {
        z && ct.allParents.exists(_ =:= y)
      })
      this.qualifiedName == ct.qualifiedName && res
    case _                  => false
  }

  def <:<(t: Type): Boolean = t match {
    // case ObjectType         => true
    case ct: ClassTypeApi   =>
      this =:= ct || this.allParents.exists(_ <:< ct)
    case _                  => false
  }
}


// trait ArrayType extends RefType {<commit_msg>Fix the subtyping relationship of class types<commit_after>package ch.usi.inf.l3.sana.ooj.types


import ch.usi.inf.l3.sana
import sana.primj
import sana.tiny
import sana.calcj
import sana.ooj
import tiny.symbols.Symbol
import tiny.names.Name
import tiny.types.Type
import calcj.types.PrimitiveType
import ooj.names.StdNames._

import scala.collection.immutable.Set


trait RefType extends Type {
  def name: Name
}


trait ClassTypeApi extends RefType {
  def qual: String
  def parents: Set[Symbol]

  def qualifiedName: String = s"$qual.${name.asString}"
  def allParents: Set[Type] = parents.flatMap { parent =>
    parent.tpe match {
      case Some(ctpe: ClassTypeApi)  => ctpe.allParents
      case _                         => Set.empty[Type]
    }
  }

  def parentTypes: Set[Type] = parents.flatMap(_.tpe)

  def =:=(t: Type): Boolean = t match {
    case ct: ClassTypeApi   =>
      lazy val res = this.allParents.foldLeft(true)((z, y) => {
        z && ct.allParents.exists(_ =:= y)
      })
      this.qualifiedName == ct.qualifiedName && res
    case _                  => false
  }

  def <:<(t: Type): Boolean = t match {
    // case ObjectType         => true
    case ct: ClassTypeApi   =>
      this =:= ct || this.parentTypes.exists(_ <:< ct)
    case _                  => false
  }
}


// trait ArrayType extends RefType {
{'fraction_non_alphanumeric': 0.11923076923076924, 'fraction_numerical': 0.0015384615384615385, 'mean_word_length': 2.500672947510094, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 21, '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': '2120886', 'n_tokens_mistral': 897, 'n_tokens_neox': 861, 'n_words': 214}