summaryrefslogtreecommitdiff
path: root/test/files/pos/t4717.scala
diff options
context:
space:
mode:
authorAleksandar Prokopec <axel22@gmail.com>2012-05-18 13:46:30 +0200
committerAleksandar Prokopec <axel22@gmail.com>2012-05-18 13:54:51 +0200
commit2aa685bcbf38b69ff52cf915a013f3f200a8fa7c (patch)
treeb7c61842afdd32c2e8e4d937d5ca4f4a054d2e9a /test/files/pos/t4717.scala
parentc7699ebe45820a34de2e9f5c9bfba3dea6b56bd3 (diff)
downloadscala-2aa685bcbf38b69ff52cf915a013f3f200a8fa7c.tar.gz
scala-2aa685bcbf38b69ff52cf915a013f3f200a8fa7c.tar.bz2
scala-2aa685bcbf38b69ff52cf915a013f3f200a8fa7c.zip
Fixes SI-4717.
A lazy val declared inside an anonymous class inside a specialized context no longer crashes Duplicators. Previously, a duplicated lazy val was assigned to the wrong owner in Duplicators: def x[B >: A]: Unit = new Bounds[B] { lazy val it = ??? // def or val okay } Above, the `it` in `$anon` in `x$mcZ$sp` had its owner set to `x$mcZ$sp` instead of `$anon`. This crashed the typer when it had to retype its lazy accessor, because there was no `lazy var it` in `$anon$`. Furthermore, the duplicated symbol wasn't being added to the list of declarations of `$anon`. Changes: 1) `invalidate` in Duplicators takes an additional parameter which is the new owner of the new symbol that has to be duplicated. If this parameter is set to `NoSymbol`, then the new owner is `context.owner`, as before. 2) the newly created lazy val symbol is being added to the list of declarations of its new owner. Removes debugging output from the previous commit. Review by dragos. @mention dragos
Diffstat (limited to 'test/files/pos/t4717.scala')
-rw-r--r--test/files/pos/t4717.scala8
1 files changed, 2 insertions, 6 deletions
diff --git a/test/files/pos/t4717.scala b/test/files/pos/t4717.scala
index 8144c0c48b..4acfe489cc 100644
--- a/test/files/pos/t4717.scala
+++ b/test/files/pos/t4717.scala
@@ -4,7 +4,7 @@
-/*
+
trait Bug1[@specialized(Boolean) A] extends TraversableOnce[A] {
def ++[B >: A](that: TraversableOnce[B]): Iterator[B] = new Iterator[B] {
@@ -14,25 +14,21 @@ trait Bug1[@specialized(Boolean) A] extends TraversableOnce[A] {
}
}
-*/
-/*
+
trait WorksFine[@specialized(Boolean) A] {
class SubBounds[B >: A] extends Bounds[B] {
lazy val it = ???
- it
}
def x[B >: A]: Unit = new SubBounds[B]
}
-*/
trait Bounds[@specialized(Boolean) A] {
// okay without `>: A`
def x[B >: A]: Unit = new Bounds[B] {
lazy val it = ??? // def or val okay
- it
}
}