Skip to content

Improve debuggability for compiler crash when using tasty reflect #6580

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

Merged
merged 1 commit into from
May 29, 2019

Conversation

liufengyun
Copy link
Contributor

Given the following macro:

import scala.tasty._
import scala.quoted._

inline def foo(x: Int): Int = ${ fooImpl('x) }

def fooImpl(x: Expr[Int])(implicit refl: Reflection) = {
  import refl._
  import util._

  val t1 : Term = x.unseal
  let (t1) { v =>
    let ('{ "hello" }.unseal) { y =>
      Select.overloaded(v, ">", Nil, y :: Nil)
    }
  }.seal.cast[Int]
}

Without the change, we get an error message like the following:

1 |def test(x: Int) = foo(x)
  |                   ^^^^^^
  |An exception occurred while executing macro expansion
  |assertion failed: no overloads available for > on Int with targs: ; args: x of types rhsTpe$_$1(x); expectedType: ?.all alternatives: def >(x: Double): Boolean, def >(x: Float): Boolean, def >(x: Long): Boolean, def >(x: Int): Boolean, def >(x: Char): Boolean, def >(x: Short): Boolean, def >(x: Byte): Boolean

With the change, mysterious type rhsTpe$_$1(x) is replaced with the type String.

Without the change, we get an error message like the following:

```
1 |def test(x: Int) = foo(x)
  |                   ^^^^^^
  |An exception occurred while executing macro expansion
  |assertion failed: no overloads available for > on Int with targs: ; args: x of types rhsTpe$_$1(x); expectedType: ?.all alternatives: def >(x: Double): Boolean, def >(x: Float): Boolean, def >(x: Long): Boolean, def >(x: Int): Boolean, def >(x: Char): Boolean, def >(x: Short): Boolean, def >(x: Byte): Boolean
```

With the change, mysterious type `rhsTpe$_$1(x)` is replaced with the type `String`.
@nicolasstucki nicolasstucki merged commit 9413cc0 into scala:master May 29, 2019
@nicolasstucki nicolasstucki deleted the macro-debuggability branch May 29, 2019 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants