-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Crash when referencing nested class in macro #19856
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
Comments
Mimimizationimport scala.quoted.*
def test(using Quotes): Any =
new {
class IdxWrapper
def foo(using Type[IdxWrapper]): Expr[Any] = '{ new IdxWrapper }
} |
[[syntax trees at end of staging]] // t/Test.scala
package <empty> {
import scala.quoted.*
final lazy module val Test$package: Test$package = new Test$package()
@SourceFile("t/Test.scala") final module class Test$package() extends Object()
{ this: Test$package.type =>
private def writeReplace(): AnyRef =
new scala.runtime.ModuleSerializationProxy(classOf[Test$package.type])
def test(using x$1: scala.quoted.Quotes): Any =
{
final class $anon() extends Object() {
class IdxWrapper() extends Object() {}
def foo(using x$1: scala.quoted.Type[IdxWrapper]):
scala.quoted.Expr[Any] = '<x$1>{new x$1.Underlying()}.apply(x$1)
}
new $anon():Object
}
}
} Here |
-- Error: t/Test.scala:6:32 ----------------------------------------------------
6 | def foo: Expr[Any] = '{ new IdxWrapper }
| ^^^^^^^^^^
|Reference to IdxWrapper within quotes requires a given scala.quoted.Type[IdxWrapper] in scope. This error message is also wrong. It should say that we cannot refer to a local class in a quote. |
Hmm, moving
(For context, having a value of type |
Compiler version
3.3.3
Minimized code
Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: