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

Regression: Failed to evaluate macro - ClassNotFoundException #19909

Closed
hmf opened this issue Mar 9, 2024 · 1 comment · Fixed by #19915
Closed

Regression: Failed to evaluate macro - ClassNotFoundException #19909

hmf opened this issue Mar 9, 2024 · 1 comment · Fixed by #19915
Assignees
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Milestone

Comments

@hmf
Copy link

hmf commented Mar 9, 2024

Compiler version

Compiles in 3.3.3.
Compilation fails in 3.4.0.

Minimized code

File: meta/src/examples/select/Wrapper.scala

package examples.select

import scala.language.dynamics
import scala.quoted.*

case class Wrapper[A](inner: A) extends Dynamic:
  transparent inline def selectDynamic(inline name: String) =
    ${selectDynamicImpl('inner, 'name)}

def selectDynamicImpl[A:Type](inner: Expr[A], name: Expr[String])(using quotes: Quotes): Expr[Any] =
  import quotes.reflect.*
  Select.unique(inner.asTerm, name.valueOrAbort).asExpr

File: meta/src/examples/select/Dynamic0.scala

package examples.select


import scala.language.dynamics
import examples.select.Wrapper

object Dynamic0:

  @main
  def runTimeError =

    val w = Wrapper(Option(1))
    println(w.isEmpty)

end Dynamic0

Output

[error] -- Error: /home/hmf/VSCodeProjects/sploty/meta/src/examples/select/Dynamic0.scala:100:14 
[error] 100 |    println(w.isEmpty)
[error]     |            ^^^^^^^^^
[error]     |Failed to evaluate macro.
[error]     |  Caused by class java.lang.ClassNotFoundException: examples.select.Wrapper$package$
[error]     |    java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
[error]     |    java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
[error]     |    dotty.tools.dotc.quoted.Interpreter.loadClass(Interpreter.scala:214)
[error]     |    dotty.tools.dotc.quoted.Interpreter.loadModule(Interpreter.scala:199)
[error]     |    dotty.tools.dotc.quoted.Interpreter.interpretedStaticMethodCall(Interpreter.scala:167)
[error]     |    dotty.tools.dotc.quoted.Interpreter.interpretTree(Interpreter.scala:80)
[error]     |    dotty.tools.dotc.transform.Splicer$SpliceInterpreter.interpretTree(Splicer.scala:266)
[error]     |    dotty.tools.dotc.quoted.Interpreter.interpretTree$$anonfun$2(Interpreter.scala:99)
[error]     |              

Expectation

Expected this to compile without changes.

Note: I find it strange that the compiler complains about a examples.select.Wrapper$package$ and not a examples.select.Wrapper class.

@hmf hmf added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 9, 2024
@hmf hmf changed the title Regression: ailed to evaluate macro - ClassNotFoundException Regression: Failed to evaluate macro - ClassNotFoundException Mar 9, 2024
@nicolasstucki nicolasstucki added area:metaprogramming:quotes Issues related to quotes and splices and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Mar 11, 2024
@nicolasstucki nicolasstucki self-assigned this Mar 11, 2024
nicolasstucki added a commit to dotty-staging/dotty that referenced this issue Mar 11, 2024
@nicolasstucki
Copy link
Contributor

This is already fixed. It will work in 3.4.1.

sjrd added a commit that referenced this issue Mar 11, 2024
@Kordyjan Kordyjan added this to the 3.4.2 milestone Mar 28, 2024
@Kordyjan Kordyjan modified the milestones: 3.4.2, 3.5.0 May 10, 2024
WojciechMazur pushed a commit that referenced this issue Jul 2, 2024
Closes #19909

Probably fixed by #19645

[Cherry-picked 2a97cb4]
WojciechMazur added a commit that referenced this issue Jul 3, 2024
Backports #19915 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:metaprogramming:quotes Issues related to quotes and splices itype:bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants