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

Macros are not compatible with structural types #7340

Open
scabug opened this issue Apr 7, 2013 · 5 comments
Open

Macros are not compatible with structural types #7340

scabug opened this issue Apr 7, 2013 · 5 comments
Labels

Comments

@scabug
Copy link

scabug commented Apr 7, 2013

This code will type-check but it will fail in runtime, as Macros dont generate runtime bytecode.

// A.scala
import scala.reflect.macros.Context
object A {
  def hello_impl(c:Context)() :c.Expr[Unit] = {
    import c.universe._
    reify {
      println("hello world")
    }
  }
}
// B.scala
import scala.language.experimental.macros
class B{
def hello():Unit = macro A.hello_impl
}
// C.scala
object C extends App{
  type greeter = {
    def hello():Unit;
  }
  val g:greeter= new B
  g.hello()
}

running such app raises java.lang.NoSuchMethodException: B.hello()

It also interferes a lot with how some java libraries work: for example Amazon DynamoDB SDK uses reflection to get all getters and setters, if some of them are defined by macros, they will be unreachable in runtime using reflection.

@scabug
Copy link
Author

scabug commented Apr 7, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7340?orig=1
Reporter: @DarkDimius
Affected Versions: 2.10.1

@scabug
Copy link
Author

scabug commented Jul 10, 2013

@scabug
Copy link
Author

scabug commented Aug 31, 2013

@xeno-by said:
scala/scala#2902

@SethTisue
Copy link
Member

closing for presumed staleness. comment/reopen if you can verify this is still relevant to current Scala

@SethTisue SethTisue removed the has PR label Mar 3, 2018
@lrytz lrytz reopened this Mar 3, 2018
@lrytz
Copy link
Member

lrytz commented Mar 3, 2018

still on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants