<commit_before>package scala.meta
package internal.hosts.scalac
package converters

import org.scalameta.invariants._
import org.scalameta.unreachable
import scala.language.implicitConversions
import scala.{Seq => _}
import scala.collection.immutable.Seq
import scala.reflect.ClassTag
import scala.tools.nsc.{Global => ScalaGlobal}
import scala.{meta => mapi}
import scala.meta.internal.{ast => m}
import scala.meta.internal.{semantic => s}
import scala.reflect.internal.Flags._
import scala.meta.internal.hosts.scalac.reflect._

// This module provides functionality for scala.reflect -> scala.meta conversions
// to keep track of scala.reflect attributes.
// We have to work hard in order to provide a DSL that allows us to use .withMattrs with scala.reflect artifacts,
// but the end result is worth it, I think.
trait ToMattrs extends ReflectToolkit with MetaToolkit {
  self: Api =>

  // ======= DEFINITION OF THE DSL =======

  protected implicit class XtensionYesDenotNoTypingTree[T <: m.Tree : YesDenotNoTyping](mtree: T) {
    def withMattrs(denotlike: DenotLike): T = {
      val denot = denotlike.sdenot
      require(denot != s.Denotation.Zero)
      implicitly[YesDenotNoTyping[T]].withMattrs(mtree, denot)
    }
    def withMattrs(gpre: g.Type, symlike: SymLike): T = {
      withMattrs(l.Denotation(gpre, symlike.lsym))
    }
    def tryMattrs(denotlike: DenotLike): T = {
      val denot = denotlike.sdenot
      if (denot != s.Denotation.Zero) withMattrs(denot)
      else mtree
    }
    def tryMattrs(gpre: g.Type, symlike: SymLike): T = {
      tryMattrs(l.Denotation(gpre, symlike.lsym))
    }
  }

  protected implicit class XtensionNoDenotYesTypingTree[T <: m.Tree : NoDenotYesTyping](mtree: T) {
    def withMattrs(tpelike: TypingLike): T = {
      val typing = tpelike.styping
      require(typing != s.Typing.Zero)
      implicitly[NoDenotYesTyping[T]].withMattrs(mtree, typing)
    }
    def tryMattrs(tpelike: TypingLike)(implicit ev: NoDenotYesTyping[T]): T = {
      val typing = tpelike.styping
      if (typing != s.Typing.Zero) withMattrs(typing)
      else mtree
    }
  }

  protected implicit class XtensionYesDenotYesTypingTree[T <: m.Tree : YesDenotYesTyping](mtree: T) {
    def withMattrs(denotlike: DenotLike): T = {
      val denot @ s.Denotation.Single(spre, ssym) = denotlike.sdenot
      val gpre = spre match { case s.Prefix.Zero => g.NoPrefix; case s.Prefix.Type(mtpe: m.Type.Arg) => mtpe.toGtype }
      val gsym = symbolTable.convert(ssym).gsymbol
      val typing = self.typing(gsym.typeSignatureIn(gpre))
      withMattrs(denot, typing)
    }
    def withMattrs(gpre: g.Type, symlike: SymLike): T = {<commit_msg>fixes a weirdness in the _root_ typing<commit_after>package scala.meta
package internal.hosts.scalac
package converters

import org.scalameta.invariants._
import org.scalameta.unreachable
import scala.language.implicitConversions
import scala.{Seq => _}
import scala.collection.immutable.Seq
import scala.reflect.ClassTag
import scala.tools.nsc.{Global => ScalaGlobal}
import scala.{meta => mapi}
import scala.meta.internal.{ast => m}
import scala.meta.internal.{semantic => s}
import scala.reflect.internal.Flags._
import scala.meta.internal.hosts.scalac.reflect._

// This module provides functionality for scala.reflect -> scala.meta conversions
// to keep track of scala.reflect attributes.
// We have to work hard in order to provide a DSL that allows us to use .withMattrs with scala.reflect artifacts,
// but the end result is worth it, I think.
trait ToMattrs extends ReflectToolkit with MetaToolkit {
  self: Api =>

  // ======= DEFINITION OF THE DSL =======

  protected implicit class XtensionYesDenotNoTypingTree[T <: m.Tree : YesDenotNoTyping](mtree: T) {
    def withMattrs(denotlike: DenotLike): T = {
      val denot = denotlike.sdenot
      require(denot != s.Denotation.Zero)
      implicitly[YesDenotNoTyping[T]].withMattrs(mtree, denot)
    }
    def withMattrs(gpre: g.Type, symlike: SymLike): T = {
      withMattrs(l.Denotation(gpre, symlike.lsym))
    }
    def tryMattrs(denotlike: DenotLike): T = {
      val denot = denotlike.sdenot
      if (denot != s.Denotation.Zero) withMattrs(denot)
      else mtree
    }
    def tryMattrs(gpre: g.Type, symlike: SymLike): T = {
      tryMattrs(l.Denotation(gpre, symlike.lsym))
    }
  }

  protected implicit class XtensionNoDenotYesTypingTree[T <: m.Tree : NoDenotYesTyping](mtree: T) {
    def withMattrs(tpelike: TypingLike): T = {
      val typing = tpelike.styping
      require(typing != s.Typing.Zero)
      implicitly[NoDenotYesTyping[T]].withMattrs(mtree, typing)
    }
    def tryMattrs(tpelike: TypingLike)(implicit ev: NoDenotYesTyping[T]): T = {
      val typing = tpelike.styping
      if (typing != s.Typing.Zero) withMattrs(typing)
      else mtree
    }
  }

  protected implicit class XtensionYesDenotYesTypingTree[T <: m.Tree : YesDenotYesTyping](mtree: T) {
    def withMattrs(denotlike: DenotLike): T = {
      val denot @ s.Denotation.Single(spre, ssym) = denotlike.sdenot
      val gpre = spre match { case s.Prefix.Zero => g.NoPrefix; case s.Prefix.Type(mtpe: m.Type.Arg) => mtpe.toGtype }
      val gsym = symbolTable.convert(ssym).gsymbol
      val gsig = {
        // TODO: Because of some strange reasons, RootPackage.info is a NullaryMethodType.
        // We need to account for that, otherwise we're going to expose a really weird type.
        if (gsym == g.rootMirror.RootPackage) g.rootMirror.RootClass.tpe
        else gsym.typeSignatureIn(gpre)
      }
      val typing = self.typing(gsig)
      withMattrs(denot, typing)
    }
    def withMattrs(gpre: g.Type, symlike: SymLike): T = {
{'fraction_non_alphanumeric': 0.11264367816091954, 'fraction_numerical': 0.0, 'mean_word_length': 3.6058631921824102, 'pattern_counts': {'":': 0, '<': 9, '<?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': '6991217', 'n_tokens_mistral': 1986, 'n_tokens_neox': 1996, 'n_words': 459}