scalacenter / tasty-query

Apache License 2.0
51 stars 11 forks source link

A ClassTypeParamSymbol can have a UniqueTypeName #415

Closed adpi2 closed 10 months ago

adpi2 commented 10 months ago

In "org.typelevel" %% "cats-core" % "2.6.1" there is this:

  // the Dummy type is to make this one more specific than catsDataMonadErrorMonadForOptionT on 2.13.x
  // see https://github.com/typelevel/cats/pull/2335#issuecomment-408249775
  implicit def catsDataMonadErrorForOptionT[F[_], E](implicit
    F0: MonadError[F, E]
  ): MonadError[OptionT[F, *], E] { type Dummy } =
    new OptionTMonadError[F, E] {
      type Dummy
      implicit val F = F0
    }

which produces a ClassTypeParamSymbol with name _$79.

TASTy Query expects that only LocalTypeParamSymbol can have a unique name and so it throws a UnsupportedOperationException:

java.lang.UnsupportedOperationException: _$79 -- /T[unique _$ 79]
    at tastyquery.Symbols$TypeSymbol.<init>(Symbols.scala:709)
    at tastyquery.Symbols$TypeSymbolWithBounds.<init>(Symbols.scala:732)
    at tastyquery.Symbols$TypeParamSymbol.<init>(Symbols.scala:778)
    at tastyquery.Symbols$ClassTypeParamSymbol.<init>(Symbols.scala:800)
    at tastyquery.Symbols$ClassTypeParamSymbol$.create(Symbols.scala:855)
    at tastyquery.reader.tasties.TreeUnpickler.createSymbols(TreeUnpickler.scala:113)

The bug is here: https://github.com/scalacenter/tasty-query/blob/06ffbf065506ef198dbf6ff19a533b02ea0bbc96/tasty-query/shared/src/main/scala/tastyquery/Symbols.scala#L708-L709