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

import api.base.{ScStableCodeReferenceElement}
import api.statements.{ScTypeAliasDefinition}
import com.intellij.psi.util.PsiTypesUtil
import decompiler.DecompilerUtil
import impl.ScalaPsiManager
import impl.toplevel.synthetic.{SyntheticClasses, ScSyntheticClass}
import resolve.ScalaResolveResult
import com.intellij.psi._
import com.intellij.psi.search.GlobalSearchScope
import api.expr.{ScSuperReference, ScThisReference}
import com.intellij.openapi.project.{Project}
import api.toplevel.typedef.{ScClass, ScObject}
import result.{Failure, Success, TypingContext}

trait ScType {
  def equiv(t: ScType): Boolean = t == this

  def conforms(t: ScType): Boolean = Conformance.conforms(t, this)

  override def toString = ScType.presentableText(this)

  def isValue: Boolean
}

trait ValueType extends ScType{
  def isValue = true
}

abstract case class StdType(val name : String, val tSuper : Option[StdType]) extends ValueType {
  def asClass(project : Project) = SyntheticClasses.get(project).byName(name).get
}

case object Any extends StdType("Any", None)

case object Null extends StdType("Null", Some(AnyRef))

case object AnyRef extends StdType("AnyRef", Some(Any))

case object Nothing extends StdType("Nothing", None)

case object Singleton extends StdType("Singleton", Some(AnyRef))

case object AnyVal extends StdType("AnyVal", Some(Any))

abstract case class ValType(override val name: String) extends StdType(name, Some(AnyVal))

object Unit extends ValType("Unit")
object Boolean extends ValType("Boolean")
object Char extends ValType("Char")
object Int extends ValType("Int")
object Long extends ValType("Long")
object Float extends ValType("Float")
object Double extends ValType("Double")
object Byte extends ValType("Byte")
object Short extends ValType("Float")

object ScType {
  def create(psiType: PsiType, project: Project): ScType = psiType match {
    case classType: PsiClassType => {
      val result = classType.resolveGenerics
      result.getElement match {
        case tp: PsiTypeParameter => ScalaPsiManager.typeVariable(tp)
        case clazz if clazz != null => {
          val tps = clazz.getTypeParameters
          val des = new ScDesignatorType(clazz)
          val substitutor = result.getSubstitutor
          tps match {
            case Array() => des
            case _ => new ScParameterizedType(des, collection.immutable.Seq(tps.map
                      (tp => {
              val psiType = substitutor.substitute(tp)
              if (psiType != null) psiType match {
                case classType: PsiClassType if classType.resolveGenerics.getElement.isInstanceOf[PsiTypeParameter] => ScalaPsiManager.typeVariable(tp)
                case _ =>ScType.create(psiType, project)
              }
              else ScalaPsiManager.typeVariable(tp)
            }).toSeq : _*))
          }
        }
        case _ => Nothing
      }
    }
    case arrayType: PsiArrayType => {
      val arrayClasses = JavaPsiFacade.getInstance(project).findClasses("scala.Array", GlobalSearchScope.allScope(project))<commit_msg>Rollbacked right ScType creating, to prevent SOE<commit_after>package org.jetbrains.plugins.scala
package lang
package psi
package types

import api.base.{ScStableCodeReferenceElement}
import api.statements.{ScTypeAliasDefinition}
import com.intellij.psi.util.PsiTypesUtil
import decompiler.DecompilerUtil
import impl.ScalaPsiManager
import impl.toplevel.synthetic.{SyntheticClasses, ScSyntheticClass}
import resolve.ScalaResolveResult
import com.intellij.psi._
import com.intellij.psi.search.GlobalSearchScope
import api.expr.{ScSuperReference, ScThisReference}
import com.intellij.openapi.project.{Project}
import api.toplevel.typedef.{ScClass, ScObject}
import result.{Failure, Success, TypingContext}

trait ScType {
  def equiv(t: ScType): Boolean = t == this

  def conforms(t: ScType): Boolean = Conformance.conforms(t, this)

  override def toString = ScType.presentableText(this)

  def isValue: Boolean
}

trait ValueType extends ScType{
  def isValue = true
}

abstract case class StdType(val name : String, val tSuper : Option[StdType]) extends ValueType {
  def asClass(project : Project) = SyntheticClasses.get(project).byName(name).get
}

case object Any extends StdType("Any", None)

case object Null extends StdType("Null", Some(AnyRef))

case object AnyRef extends StdType("AnyRef", Some(Any))

case object Nothing extends StdType("Nothing", None)

case object Singleton extends StdType("Singleton", Some(AnyRef))

case object AnyVal extends StdType("AnyVal", Some(Any))

abstract case class ValType(override val name: String) extends StdType(name, Some(AnyVal))

object Unit extends ValType("Unit")
object Boolean extends ValType("Boolean")
object Char extends ValType("Char")
object Int extends ValType("Int")
object Long extends ValType("Long")
object Float extends ValType("Float")
object Double extends ValType("Double")
object Byte extends ValType("Byte")
object Short extends ValType("Float")

object ScType {
  def create(psiType: PsiType, project: Project): ScType = psiType match {
    case classType: PsiClassType => {
      val result = classType.resolveGenerics
      result.getElement match {
        case tp: PsiTypeParameter => ScalaPsiManager.typeVariable(tp)
        case clazz if clazz != null => {
          val tps = clazz.getTypeParameters
          val des = new ScDesignatorType(clazz)
          val substitutor = result.getSubstitutor
          tps match {
            case Array() => des
            case _ => new ScParameterizedType(des, collection.immutable.Seq(tps.map
                      (tp => ScalaPsiManager.typeVariable(tp)).toSeq : _*))
          }
        }
        case _ => Nothing
      }
    }
    case arrayType: PsiArrayType => {
      val arrayClasses = JavaPsiFacade.getInstance(project).findClasses("scala.Array", GlobalSearchScope.allScope(project))
{'fraction_non_alphanumeric': 0.0949505116591176, 'fraction_numerical': 0.0, 'mean_word_length': 4.135228251507321, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6125386', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1709, 'n_words': 466}