diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2013-05-30 17:44:29 +0200 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2013-05-30 18:57:32 +0200 |
commit | 608f577e0a565c746f94b9b52ceadf9728b179b4 (patch) | |
tree | 6586576ad532ee94959306c06892eb8e69d94cee /test/files/run | |
parent | 681f2070053bc6f3133425b44083fe056bfeb1fa (diff) | |
download | scala-608f577e0a565c746f94b9b52ceadf9728b179b4.tar.gz scala-608f577e0a565c746f94b9b52ceadf9728b179b4.tar.bz2 scala-608f577e0a565c746f94b9b52ceadf9728b179b4.zip |
SI-6841 Fix bug at the intersection of DelayedInit and named args
The DelayedInit transformation analyses the constructor to partition
regular initialization from calls to super constructors / trait
initializers.
It failed to find such super calls if they were nested in a Block,
which can happens when using named or default arguments.
This commit makes that code peer into Blocks to correctly partition
the constructor statements.
This change doesn't affect the result of run/t4680.scala, which was
mentioned in nearby comments and which chronicles bugs with DelayedInit
when used in inheritance hierarchies.
Diffstat (limited to 'test/files/run')
-rw-r--r-- | test/files/run/t6481.check | 4 | ||||
-rw-r--r-- | test/files/run/t6481.scala | 13 |
2 files changed, 17 insertions, 0 deletions
diff --git a/test/files/run/t6481.check b/test/files/run/t6481.check new file mode 100644 index 0000000000..7ec29631b1 --- /dev/null +++ b/test/files/run/t6481.check @@ -0,0 +1,4 @@ +delayed init +new foo(1, 2) +delayed init +new foo(b = 2, a = 1) diff --git a/test/files/run/t6481.scala b/test/files/run/t6481.scala new file mode 100644 index 0000000000..125da3b15a --- /dev/null +++ b/test/files/run/t6481.scala @@ -0,0 +1,13 @@ +abstract class foo(a: Int, b: Int) extends scala.DelayedInit { + def delayedInit(x: => Unit) { + println("delayed init"); + x + } +} + +object Test { + def main(args: Array[String]) { + new foo(1, 2) { println("new foo(1, 2)") } + new foo(b = 2, a = 1) { println("new foo(b = 2, a = 1)") } + } +} |