summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-02-08 12:12:42 +0000
committerHubert Plociniczak <hubert.plociniczak@epfl.ch>2011-02-08 12:12:42 +0000
commit496dc761189182e04c424750ba63077d62dcf78b (patch)
treefe4779705256de274120dce0da66f5b2dcfb20e6
parent75fe0c8bd628df9abbc6a90b5046757b48538294 (diff)
downloadscala-496dc761189182e04c424750ba63077d62dcf78b.tar.gz
scala-496dc761189182e04c424750ba63077d62dcf78b.tar.bz2
scala-496dc761189182e04c424750ba63077d62dcf78b.zip
Closes #3986 plus some cleanup. no review
-rw-r--r--src/compiler/scala/tools/nsc/transform/Constructors.scala4
-rw-r--r--src/compiler/scala/tools/nsc/util/SourceFile.scala6
-rw-r--r--test/files/pos/t3986.scala5
3 files changed, 11 insertions, 4 deletions
diff --git a/src/compiler/scala/tools/nsc/transform/Constructors.scala b/src/compiler/scala/tools/nsc/transform/Constructors.scala
index e7325c4f18..e106ee04be 100644
--- a/src/compiler/scala/tools/nsc/transform/Constructors.scala
+++ b/src/compiler/scala/tools/nsc/transform/Constructors.scala
@@ -170,7 +170,9 @@ abstract class Constructors extends Transform with ast.TreeDSL {
val fields = presupers filter (
vdef => nme.localToGetter(vdef.name) == name)
assert(fields.length == 1)
- constrStatBuf += mkAssign(fields.head.symbol, Ident(stat.symbol))
+ val to = fields.head.symbol
+ if (!to.tpe.isInstanceOf[ConstantType])
+ constrStatBuf += mkAssign(to, Ident(stat.symbol))
case _ =>
}
}
diff --git a/src/compiler/scala/tools/nsc/util/SourceFile.scala b/src/compiler/scala/tools/nsc/util/SourceFile.scala
index ca4559d717..90a9057f01 100644
--- a/src/compiler/scala/tools/nsc/util/SourceFile.scala
+++ b/src/compiler/scala/tools/nsc/util/SourceFile.scala
@@ -46,7 +46,7 @@ abstract class SourceFile {
final def skipWhitespace(offset: Int): Int =
if (content(offset).isWhitespace) skipWhitespace(offset + 1) else offset
- def identifier(pos: Position, compiler: Global): Option[String] = None
+ def identifier(pos: Position): Option[String] = None
}
object ScriptSourceFile {
@@ -101,12 +101,12 @@ class BatchSourceFile(val file : AbstractFile, val content: Array[Char]) extends
def start = 0
def isSelfContained = true
- override def identifier(pos: Position, compiler: Global) =
+ override def identifier(pos: Position) =
if (pos.isDefined && pos.source == this && pos.point != -1) {
def isOK(c: Char) = isIdentifierPart(c) || isOperatorPart(c)
Some(new String(content drop pos.point takeWhile isOK))
} else {
- super.identifier(pos, compiler)
+ super.identifier(pos)
}
def isLineBreak(idx: Int) =
diff --git a/test/files/pos/t3986.scala b/test/files/pos/t3986.scala
new file mode 100644
index 0000000000..10c4eb435f
--- /dev/null
+++ b/test/files/pos/t3986.scala
@@ -0,0 +1,5 @@
+object Test {
+ def main(args: Array[String]) {
+ new { val x = "abc" } with AnyRef { }
+ }
+}