Skip to content

Instantly share code, notes, and snippets.

@dozed
Created June 24, 2015 20:38
Show Gist options
  • Save dozed/55241483812bc102229d to your computer and use it in GitHub Desktop.
Save dozed/55241483812bc102229d to your computer and use it in GitHub Desktop.
// this is the macro expansion
RescopingMacros.transplant({
class X extends scala.AnyRef {
def <init>(): X = {
X.super.<init>();
()
};
private[this] val request: Int = 1;
<stable> <accessor> def request: Int = X.this.request;
def print1: Unit = scala.this.Predef.println(X.this.request)
};
RescopingTest.this.foo(RescopingTest.this.request)
})
// this is the expanded code, X.this.request refers now to cls$macro$2.this.request, which is wrong
{
class cls$macro$2 extends StableResult {
def <init>(): cls$macro$2 = {
cls$macro$2.super.<init>();
()
};
private[this] val is: Int = ({
class X extends scala.AnyRef {
def <init>(): X = {
X.super.<init>();
()
};
private[this] val request: Int = 1;
<stable> <accessor> def request: Int = X.this.request;
def print1: Unit = scala.this.Predef.println(cls$macro$2.this.request) // should be X.this.request
};
RescopingTest.this.foo(cls$macro$2.this.request)
}: Int);
<stable> <accessor> def is: Int = cls$macro$2.this.is
};
val res$macro$1: cls$macro$2 = new cls$macro$2();
res$macro$1.is
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment