Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TagMacro: Dotty: return correct closestClass in Tags #133

Closed
neko-kai opened this issue Feb 2, 2021 · 1 comment
Closed

TagMacro: Dotty: return correct closestClass in Tags #133

neko-kai opened this issue Feb 2, 2021 · 1 comment
Assignees
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed scala3 scalac-issue Blocked by scalac

Comments

@neko-kai
Copy link
Member

neko-kai commented Feb 2, 2021

Reported in #116 (comment)

Dotty version currently always uses classOf[Any] as the closestClass instead of finding the LUB of a type as the Scala 2 version does.

@neko-kai neko-kai added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed bug Something isn't working and removed enhancement New feature or request labels Feb 4, 2021
@neko-kai
Copy link
Member Author

neko-kai commented Feb 4, 2021

Note that it's not enought to splice classOf[T], we should mirror behavior of closestClass for Scala 2:

  @inline
  private[this] final def closestClass(properTypeStrongCtor: Type): c.Expr[Class[_]] = {
    // unfortunately .erasure returns trash for intersection types
    val tpeLub = properTypeStrongCtor match {
      case r: RefinedTypeApi => lub(r.parents)
      case _ => properTypeStrongCtor
    }
    c.Expr[Class[_]](q"_root_.scala.Predef.classOf[${tpeLub.erasure}]")
  }

That is, the complexity is essentially in finding analogue of c.universe.lub function in the new tasty-reflect API and extracting the LUB for intersection type and using the default behavior of classOf for all other cases.

@pshirshov pshirshov added the scalac-issue Blocked by scalac label Aug 2, 2022
@pshirshov pshirshov changed the title Dotty: return correct closestClass in Tags TagMacro Dotty: return correct closestClass in Tags Aug 2, 2022
@pshirshov pshirshov changed the title TagMacro Dotty: return correct closestClass in Tags TagMacro: Dotty: return correct closestClass in Tags Aug 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed scala3 scalac-issue Blocked by scalac
Projects
None yet
Development

No branches or pull requests

2 participants