Skip to content

Synthesize class tags in top level splices. #4515

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

Closed
nicolasstucki opened this issue May 11, 2018 · 1 comment
Closed

Synthesize class tags in top level splices. #4515

nicolasstucki opened this issue May 11, 2018 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

object Foo {
  inline def foo[X](x: X): Unit = ~fooImpl('(x))
  def fooImpl[X: quoted.Type](x: quoted.Expr[X]): quoted.Expr[Unit] = '()
}

currently fails with

3 |  inline def foo[X](x: X): Unit = ~fooImpl('(x))
  |                                                ^
  |no implicit argument of type quoted.Type[X] was found for parameter evidence$1 of method fooImpl in object Foo

We need to write instead

  inline def foo[X](x: X): Unit = ~fooImpl('(x))('[X])

We should be able to synthesize classtags inside top level splices to reduce this syntactic overhead.

This would be a change in Typer and not in ReifyQuotes.

@nicolasstucki
Copy link
Contributor Author

We also need to make Universe.compilationUniverse available in this same scope. A solution would be to add Universe._ to the scope of a top level splice.
Converting

inline def foo[X](x: X): Unit = ~{ ... }

into

inline def foo[X](x: X): Unit = ~{ import Universe._; ... }

This must be done durring typing or before.

Then we can add implicit inline def tp[T]: scala.quoted.Type[T] = scala.quoted.Type.apply[T] to Universe to provide the type tags.

nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 6, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 6, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 11, 2018
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Aug 27, 2018
nicolasstucki added a commit that referenced this issue Aug 28, 2018
Fix #4515: Synthesize implicit type tags in transparent methods
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants