<commit_before>package org.jetbrains.plugins.scala.lang.psi.types

object Bounds {

  def glb(t1: ScType, t2: ScType) = {
    if (t1.conforms(t2)) t1
    else if (t2.conforms(t1)) t2
    else new ScCompoundType(Array(t1, t2), Seq.empty, Seq.empty)
  }

  def lub(t1: ScType, t2: ScType): ScType = {
    if (t1.conforms(t2)) t2
    else if (t2.conforms(t1)) t1
    else (t1, t2) match {
      //Function types
      case (ScFunctionType(rt1, params1), ScFunctionType(rt2, params2))
        if params1.length == params2.length => {
        val px = for ((p1, p2) <- params1.toList.zip(params2.toList)) yield glb(p1, p2)
        ScFunctionType(lub(rt1, rt2), px)
      }
      //Tuple types
      case (ScTupleType(comps1), ScTupleType(comps2))
        if comps1.length == comps2.length => {
        val cx = for ((c1, c2) <- comps1.toList.zip(comps2.toList)) yield lub(c1, c2)
        ScTupleType(cx)
      }
      case (ScTypeVariable(_, Nil, _, upper), _) => lub(upper, t2)
      case (_, ScTypeVariable(_, Nil, _, upper)) => lub(t1, upper)
      case (ScTypeAliasType(_, Nil, _, upper), _) => lub(upper, t2)
      case (_, ScTypeAliasType(_, Nil, _, upper)) => lub(t1, upper)
      case (s: ScSingletonType, _) => lub(s.pathType, t2)
      case (_, s: ScSingletonType) => lub(t1, s.pathType)
      case _ => Any //todo
    }
  }
}<commit_msg>let us argue this is not clearer:)<commit_after>package org.jetbrains.plugins.scala.lang.psi.types

object Bounds {

  def glb(t1: ScType, t2: ScType) = {
    if (t1.conforms(t2)) t1
    else if (t2.conforms(t1)) t2
    else new ScCompoundType(Array(t1, t2), Seq.empty, Seq.empty)
  }

  def lub(t1: ScType, t2: ScType): ScType = {
    if (t1.conforms(t2)) t2
    else if (t2.conforms(t1)) t1
    else (t1, t2) match {
      case (ScFunctionType(rt1, p1), ScFunctionType(rt2, p2)) if p1.length == p2.length =>
        ScFunctionType(lub(rt1, rt2), p1.toList.zip(p2.toList).map{case (t1, t2) => glb(t1, t2)})
      case (ScTupleType(c1), ScTupleType(c2)) if c1.length == c2.length =>
        ScTupleType(c1.toList.zip(c2.toList).map{case (t1, t2) => lub(t1, t2)})

      case (ScTypeVariable(_, Nil, _, upper), _) => lub(upper, t2)
      case (_, ScTypeVariable(_, Nil, _, upper)) => lub(t1, upper)
      case (ScTypeAliasType(_, Nil, _, upper), _) => lub(upper, t2)
      case (_, ScTypeAliasType(_, Nil, _, upper)) => lub(t1, upper)
      case (s: ScSingletonType, _) => lub(s.pathType, t2)
      case (_, s: ScSingletonType) => lub(t1, s.pathType)
      case _ => Any //todo
    }
  }
}
{'fraction_non_alphanumeric': 0.16673251679178192, 'fraction_numerical': 0.039510075069142635, 'mean_word_length': 3.0063291139240507, 'pattern_counts': {'":': 0, '<': 5, '<?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': '3317158', 'n_tokens_mistral': 1043, 'n_tokens_neox': 1020, 'n_words': 224}