summaryrefslogtreecommitdiff
path: root/test/files/run/t5080.scala
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2011-10-16 16:57:20 +0000
committerPaul Phillips <paulp@improving.org>2011-10-16 16:57:20 +0000
commit581fad662c4d7e33613df8d2089a3a730001dc38 (patch)
tree82e2d3af9f1170aae6dd544969741e31fd8d6e09 /test/files/run/t5080.scala
parent7d772368d579fa0933dda935100836e140d332a2 (diff)
downloadscala-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/files/run/t5080.scala')
-rw-r--r--test/files/run/t5080.scala24
1 files changed, 24 insertions, 0 deletions
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
+}