diff options
author | Som Snytt <som.snytt@gmail.com> | 2012-04-27 02:02:55 -0700 |
---|---|---|
committer | Som Snytt <som.snytt@gmail.com> | 2012-04-28 01:39:54 -0700 |
commit | 77b577a5aeab782b64b39b3a812c35fdd8ab265a (patch) | |
tree | c8c832e553580257d67b90e23e8599e45182676a /src/compiler/scala/reflect/internal/StdNames.scala | |
parent | 2a9cce8a6859a34c259d0b399687df3a242de16b (diff) | |
download | scala-77b577a5aeab782b64b39b3a812c35fdd8ab265a.tar.gz scala-77b577a5aeab782b64b39b3a812c35fdd8ab265a.tar.bz2 scala-77b577a5aeab782b64b39b3a812c35fdd8ab265a.zip |
SI-5543: Ctor default arg wrongly scoped (revised)
This patch fixes the motivating bug by detecting when a method is
the default arg getter for a constructor parameter. That requires
fixing a secondary bug where an arbitrary string was used to encode
<init> in lieu of <init>.encode. There is no speculative mangling.
Diffstat (limited to 'src/compiler/scala/reflect/internal/StdNames.scala')
-rw-r--r-- | src/compiler/scala/reflect/internal/StdNames.scala | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index a55efea2e6..76660ac3f1 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -272,6 +272,7 @@ trait StdNames { val BITMAP_PREFIX = "bitmap$" val CHECK_IF_REFUTABLE_STRING = "check$ifrefutable$" val DEFAULT_GETTER_STRING = "$default$" + val DEFAULT_GETTER_INIT_STRING = "$lessinit$greater" // CONSTRUCTOR.encoded, less is more val DO_WHILE_PREFIX = "doWhile$" val EVIDENCE_PARAM_PREFIX = "evidence$" val EXCEPTION_RESULT_PREFIX = "exceptionResult" @@ -413,14 +414,19 @@ trait StdNames { name.subName(0, name.length - SETTER_SUFFIX.length) } + // Nominally, name$default$N, encoded for <init> def defaultGetterName(name: Name, pos: Int): TermName = { - val prefix = if (isConstructorName(name)) "init" else name + val prefix = if (isConstructorName(name)) DEFAULT_GETTER_INIT_STRING else name newTermName(prefix + DEFAULT_GETTER_STRING + pos) } + // Nominally, name from name$default$N, CONSTRUCTOR for <init> def defaultGetterToMethod(name: Name): TermName = { val p = name.pos(DEFAULT_GETTER_STRING) - if (p < name.length) name.toTermName.subName(0, p) - else name.toTermName + if (p < name.length) { + val q = name.toTermName.subName(0, p) + // i.e., if (q.decoded == CONSTRUCTOR.toString) CONSTRUCTOR else q + if (q.toString == DEFAULT_GETTER_INIT_STRING) CONSTRUCTOR else q + } else name.toTermName } // If the name ends with $nn where nn are |