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

Can't define a macro in a class with an AnyVal param: an expression of type Null is ineligible for implicit conversion #9884

Open
scabug opened this issue Aug 10, 2016 · 2 comments

Comments

@scabug
Copy link

scabug commented Aug 10, 2016

It is impossible to define a macro inside a class with an AnyVal parameter, referencing an object with the same name as the class.
This fails to compile with: "error: an expression of type Null is ineligible for implicit conversion"

class Foo(a: Boolean /* or Int or Double or ...*/) {
    def bar = macro Foo.impl
    def baz = macro OtherObject.impl   //works
}

If the AnyVal parameter is replaced with AnyRef or a subclass of AnyRef, the error message is "error: not found: value Foo", as intended.
Additionally,

class Foo[A <: Boolean](a: A) { ... } 

fails with right error message.

@scabug
Copy link
Author

scabug commented Aug 10, 2016

Imported From: https://issues.scala-lang.org/browse/SI-9884?orig=1
Reporter: Jendrik Wenke (Jendrik3)
Affected Versions: 2.11.6, 2.11.7

@exoego
Copy link

exoego commented Jun 24, 2020

This seems still happening on Scala 2.13.2.

class MyMacro(isFoo: Boolean = true) extends StaticAnnotation {
  def macroTransform(annottees: Any*): Any = macro MyMacro.impl
}
object MyMacro {
  def impl(c: whitebox.Context)(annottees: c.Expr[Any]*) = ???
}

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

4 participants