Skip to content

Fail to find macro method when parameter is interface #4492

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 9, 2018 · 1 comment
Closed

Fail to find macro method when parameter is interface #4492

nicolasstucki opened this issue May 9, 2018 · 1 comment

Comments

@nicolasstucki
Copy link
Contributor

trait Index
object Index {
  inline def succ(prev: Index): Unit = ~{ '(println("Ok")) }
}
object Test {
  def main(args: Array[String]): Unit = {
    Index.succ(null)
  }
}

fails with

3 |    Index.succ(null)
  |    ^^^^^^^^^^^^^^^^
  |Could not find interpreted method Index.succ with parameters List(interface Index)
@nicolasstucki
Copy link
Contributor Author

As discussed, the solution is to call the methods on the module instance instead of the static methods.

Here we get the Class of the class (not module) and we use null to say that this is a static method. Instead we should return the class of the module and return the instance of that module by calling the MODULE$ method (or field) on it.

nicolasstucki added a commit that referenced this issue May 24, 2018
Fix #4492: Load module instance instead of calling static 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