diff options
author | Paul Phillips <paulp@improving.org> | 2011-10-16 16:57:20 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2011-10-16 16:57:20 +0000 |
commit | 581fad662c4d7e33613df8d2089a3a730001dc38 (patch) | |
tree | 82e2d3af9f1170aae6dd544969741e31fd8d6e09 /test | |
parent | 7d772368d579fa0933dda935100836e140d332a2 (diff) | |
download | scala-581fad662c4d7e33613df8d2089a3a730001dc38.tar.gz scala-581fad662c4d7e33613df8d2089a3a730001dc38.tar.bz2 scala-581fad662c4d7e33613df8d2089a3a730001dc38.zip |
Fix for multiple evaluation in structural calls.
An interesting bug during cleanup: runtime checks on the target of a
structural invocation duplicated the selection without regard for the
fact that it might be an expression. So if the name of the method being
invoked allowed the possibility that the target was a primitive type
(such as "toInt") the expression would be evaluated three times.
Closes SI-5080, no review.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/run/t5080.check | 1 | ||||
-rw-r--r-- | test/files/run/t5080.scala | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/test/files/run/t5080.check b/test/files/run/t5080.check new file mode 100644 index 0000000000..1385f264af --- /dev/null +++ b/test/files/run/t5080.check @@ -0,0 +1 @@ +hey diff --git a/test/files/run/t5080.scala b/test/files/run/t5080.scala new file mode 100644 index 0000000000..ce72d13a54 --- /dev/null +++ b/test/files/run/t5080.scala @@ -0,0 +1,24 @@ +object Test extends App { + + abstract class Value { + } + + case class Num(value: Int) extends Value { + override def toString = value.toString; + } + + implicit def conversions(x: Value) = new { + def toInt = + x match { + case Num(n) => n + case _ => throw new RuntimeException + } + } + + def eval(v: Value): Value = { + println("hey") + Num(1) + } + + eval(Num(1)).toInt +} |