Created
January 21, 2026 13:49
-
-
Save zainab-ali/00dacdf2c9c694cb994b02986555cb91 to your computer and use it in GitHub Desktop.
Scalameta `q` macro behaves strangely when substituting types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //> using scala 2.13.18 | |
| //> using dep "org.scalameta::scalameta::4.14.2" | |
| import scala.meta._ | |
| val fooType = t"Foo" | |
| val code = q""" | |
| type Bar = ${fooType} | |
| val qux = "any message" | |
| """ | |
| println(code.syntax) | |
| // Expected | |
| // { | |
| // type Bar = Foo | |
| // val qux = "any message" | |
| // } | |
| // Actual | |
| // { | |
| // type Bar = Foo | |
| // val qux = | |
| // } | |
| // Affected versions: 4.14.3, 4.14.4, 4.14.5 | |
| // Note that 4.14.2 is correct |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment