Skip to content

Instantly share code, notes, and snippets.

@rxin
Created November 1, 2014 21:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rxin/6be132f46b72c27d8f89 to your computer and use it in GitHub Desktop.
Save rxin/6be132f46b72c27d8f89 to your computer and use it in GitHub Desktop.
test.scala on constructor parameter shadowing
class LegalPerson(name: String) {
def aaaaaaaaaa = name
}
class DoomedPerson(name: String) extends LegalPerson(name) {
def curName = name
}
class AAAAA(val xxxx: Int)
class BBBBBB(xxxx: Int) extends AAAAA(xxxx) {
def ppppp() { println(xxxx) }
}
[[syntax trees at end of cleanup]] // test.scala
package <empty> {
class LegalPerson extends Object {
<paramaccessor> private[this] val name: String = _;
def aaaaaaaaaa(): String = LegalPerson.this.name;
def <init>(name: String): LegalPerson = {
LegalPerson.this.name = name;
LegalPerson.super.<init>();
()
}
};
class DoomedPerson extends LegalPerson {
<paramaccessor> private[this] val name: String = _;
def curName(): String = DoomedPerson.this.name;
def <init>(name: String): DoomedPerson = {
DoomedPerson.this.name = name;
DoomedPerson.super.<init>(name);
()
}
};
class AAAAA extends Object {
<paramaccessor> private[this] val xxxx: Int = _;
<stable> <accessor> <paramaccessor> def xxxx(): Int = AAAAA.this.xxxx;
def <init>(xxxx: Int): AAAAA = {
AAAAA.this.xxxx = xxxx;
AAAAA.super.<init>();
()
}
};
class BBBBBB extends AAAAA {
def ppppp(): Unit = scala.this.Predef.println(scala.Int.box((BBBBBB.super.xxxx(): Int)));
def <init>(xxxx: Int): BBBBBB = {
BBBBBB.super.<init>(xxxx);
()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment