<commit_before>/**
* @author ven
*/
package org.jetbrains.plugins.scala.lang.psi.types

import com.intellij.openapi.util.Key
import com.intellij.psi.PsiTypeParameter

object ScSubstitutor {
  val empty = new ScSubstitutor

  val key : Key[ScSubstitutor] = Key.create("scala substitutor key")
}

class ScSubstitutor(val map : Map[PsiTypeParameter, ScType]) {

  def this() = {
    this(Map.empty)
  }

  def put(p : PsiTypeParameter, t : ScType) = new ScSubstitutor(map + ((p, t)))

  def subst(p : PsiTypeParameter) = {
    map.get(p) match {
      case None => new ScDesignatorType(p)
      case Some(v) => v
    }
  }

  def subst (t : ScType) : ScType = {
    t match {
      case ScFunctionType(ret, params) => new ScFunctionType(subst(ret), params map (t => subst(t)))
      case ScParameterizedType (td, s) => td match {
        case tp : PsiTypeParameter => subst(tp)
        case _ => {
          val newMap = map transform ((tp : PsiTypeParameter, t : ScType) => subst(s.subst(t)))
          new ScParameterizedType(td, new ScSubstitutor(newMap))
        }
      }
      case _ => t //todo
    }
  }
}

import com.intellij.psi.PsiMethod
class Signature(val types : Seq[ScType], val method : PsiMethod, val substitutor : ScSubstitutor) {
  def equiv(other : Signature) : Boolean = {
    method.getName == other.method.getName &&
    types.equalsWith(other.types) {(t1, t2) => substitutor.subst(t1) equiv other.substitutor.subst(t2)}
  }
}<commit_msg>for signatures need PsiMethods themselves:(<commit_after>/**
* @author ven
*/
package org.jetbrains.plugins.scala.lang.psi.types

import com.intellij.openapi.util.Key
import com.intellij.psi.PsiTypeParameter

object ScSubstitutor {
  val empty = new ScSubstitutor

  val key : Key[ScSubstitutor] = Key.create("scala substitutor key")
}

class ScSubstitutor(val map : Map[PsiTypeParameter, ScType]) {

  def this() = {
    this(Map.empty)
  }

  def put(p : PsiTypeParameter, t : ScType) = new ScSubstitutor(map + ((p, t)))

  def subst(p : PsiTypeParameter) = {
    map.get(p) match {
      case None => new ScDesignatorType(p)
      case Some(v) => v
    }
  }

  def subst (t : ScType) : ScType = {
    t match {
      case ScFunctionType(ret, params) => new ScFunctionType(subst(ret), params map (t => subst(t)))
      case ScParameterizedType (td, s) => td match {
        case tp : PsiTypeParameter => subst(tp)
        case _ => {
          val newMap = map transform ((tp : PsiTypeParameter, t : ScType) => subst(s.subst(t)))
          new ScParameterizedType(td, new ScSubstitutor(newMap))
        }
      }
      case _ => t //todo
    }
  }
}

import com.intellij.psi.PsiMethod
class Signature(val types : Seq[ScType], val method : PsiMethod, val substitutor : ScSubstitutor) {
  val name = method.getName
  def equiv(other : Signature) : Boolean = {
    name == other.name &&
    types.equalsWith(other.types) {(t1, t2) => substitutor.subst(t1) equiv other.substitutor.subst(t2)}
  }
}
{'fraction_non_alphanumeric': 0.12831423895253682, 'fraction_numerical': 0.002618657937806874, 'mean_word_length': 2.7775030902348576, 'pattern_counts': {'":': 0, '<': 3, '<?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': '682046', 'n_tokens_mistral': 1103, 'n_tokens_neox': 1034, 'n_words': 241}