aboutsummaryrefslogtreecommitdiff
path: root/tests/pos/harmonize.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-05-23 10:20:53 +0200
committerMartin Odersky <odersky@gmail.com>2015-05-27 20:08:28 +0200
commit421f29573190fca94e595bbfe30619a23b052aad (patch)
tree0247d7aa90d6176b9cd15d0331ec371d1a605d07 /tests/pos/harmonize.scala
parent8dd3466ff605db006934697edd7b8ffd9af4bf7f (diff)
downloaddotty-421f29573190fca94e595bbfe30619a23b052aad.tar.gz
dotty-421f29573190fca94e595bbfe30619a23b052aad.tar.bz2
dotty-421f29573190fca94e595bbfe30619a23b052aad.zip
Introduce harmonization of numeric arguments
Harmonization is Dotty's alternative to Scala 2's notion of weak conformance. It is less powerful but also less entangled with the core type system. The idea is that in some specific contexts trees that all have primitive numeric types will be converted as necessary so that they all have the same numeric type. These tree sets are: - the two branches of an if - the alternatives of a match - the body together with the catch blocks of a try - the arguments of a vararg parameter Examples are in the test file, harmonize.scala.
Diffstat (limited to 'tests/pos/harmonize.scala')
-rw-r--r--tests/pos/harmonize.scala28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/pos/harmonize.scala b/tests/pos/harmonize.scala
new file mode 100644
index 000000000..267db6134
--- /dev/null
+++ b/tests/pos/harmonize.scala
@@ -0,0 +1,28 @@
+object Test {
+
+ def main(args: Array[String]) = {
+ val x = true
+ val n = 1
+/* val y = if (x) 'A' else n
+ val z: Int = y
+
+ val yy = n match {
+ case 1 => 'A'
+ case 2 => n
+ case 3 => 1.0
+ }
+ val zz: Double = yy
+
+ val a = try {
+ 'A'
+ } catch {
+ case ex: Exception => n
+ case ex: Error => 3L
+ }
+ val b: Long = a
+*/
+ val xs = List(1.0, n, 'c')
+ val ys: List[Double] = xs
+ }
+
+}