From 16d3cf1f8f22c04559145b35bb5f6c0aacfb0d8c Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 23 Jul 2007 18:22:29 +0000 Subject: many bug fixes; short syntax for structural types. --- test/files/neg/bug835.check | 9 +++++++-- test/files/neg/bug875.check | 12 ++++++++---- test/files/pos/bug602.scala | 4 ++++ test/files/run/existentials.scala | 3 +++ test/files/run/regularpatmatnew.scala | 2 +- test/files/run/withIndex.check | 2 ++ test/files/run/withIndex.scala | 7 ++++++- 7 files changed, 31 insertions(+), 8 deletions(-) (limited to 'test/files') diff --git a/test/files/neg/bug835.check b/test/files/neg/bug835.check index 83db589280..79ea97b71f 100644 --- a/test/files/neg/bug835.check +++ b/test/files/neg/bug835.check @@ -1,4 +1,9 @@ -bug835.scala:2: error: _*-argument may not appear after other arguments matching a *-parameter +bug835.scala:2: error: no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters) + Console.println(List(List(1, 2, 3) : _*, List(4, 5, 6) : _*)) + ^ +bug835.scala:2: error: no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters) Console.println(List(List(1, 2, 3) : _*, List(4, 5, 6) : _*)) ^ -one error found +two errors found diff --git a/test/files/neg/bug875.check b/test/files/neg/bug875.check index 63ad0f7eb0..d547c8d69c 100644 --- a/test/files/neg/bug875.check +++ b/test/files/neg/bug875.check @@ -1,13 +1,17 @@ -bug875.scala:3: error: _*-argument may not appear after other arguments matching a *-parameter +bug875.scala:3: error: no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters) val ys = List(1, 2, 3, xs: _*) ^ -bug875.scala:6: error: _*-argument does not correspond to *-parameter +bug875.scala:6: error: no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters) mkList(xs: _*) ^ -bug875.scala:15: error: _*-argument may not appear after other arguments matching a *-parameter +bug875.scala:15: error: no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters) f(true, 1, xs: _*) ^ -bug875.scala:16: error: _*-argument may not appear after other arguments matching a *-parameter +bug875.scala:16: error: no `: _*' annotation allowed here +(such annotations are only allowed in arguments to *-parameters) g(1, xs:_*) ^ four errors found diff --git a/test/files/pos/bug602.scala b/test/files/pos/bug602.scala index 60aef1dfd0..5877d08ddc 100644 --- a/test/files/pos/bug602.scala +++ b/test/files/pos/bug602.scala @@ -1,6 +1,10 @@ package com.mosol.sl; case class Span[K <: Ordered[K]](low: Option[K], high: Option[K]) extends Function1[K, boolean] { + override def equals(x$1: Any): Boolean = x$1 match { + case Span((low$0 @ _), (high$0 @ _)) if low$0.equals(low).$amp$amp(high$0.equals(high)) => true + case _ => false + } def apply(k: K): boolean = this match { case Span(Some(low), Some(high)) => (k >= low && k <= high) case Span(Some(low), None) => (k >= low) diff --git a/test/files/run/existentials.scala b/test/files/run/existentials.scala index a08a9da9b3..9dc9855a75 100755 --- a/test/files/run/existentials.scala +++ b/test/files/run/existentials.scala @@ -52,6 +52,9 @@ object Bug1189 { object Test extends Application { + val x = { class I[T]; (new C(new I[String]), new C(new I[Int])) } + val y: (C[X], C[Y]) forSome { type X; type Y } = x + def foo(x : Counter[T] { def name : String } forSome { type T }) = x match { case ctr: Counter[t] => val c = ctr.newCounter diff --git a/test/files/run/regularpatmatnew.scala b/test/files/run/regularpatmatnew.scala index 0457cd6d6c..c610b80444 100644 --- a/test/files/run/regularpatmatnew.scala +++ b/test/files/run/regularpatmatnew.scala @@ -105,7 +105,7 @@ object Test { case Bar(xs@_*) => xs // this should be optimized away to a pattern Bar(xs) case _ => Nil } - assertEquals("res instance"+res.isInstanceOf[Seq[Con]]+" res(0)="+res(0), true, res.isInstanceOf[Seq[Foo]] && res(0) == Foo() ) + assertEquals("res instance"+res.isInstanceOf[Seq[Con] forSome { type Con }]+" res(0)="+res(0), true, res.isInstanceOf[Seq[Foo] forSome { type Foo}] && res(0) == Foo() ) } } diff --git a/test/files/run/withIndex.check b/test/files/run/withIndex.check index 6a9c7aaadb..e8060bb1d7 100644 --- a/test/files/run/withIndex.check +++ b/test/files/run/withIndex.check @@ -1,3 +1,5 @@ +warning: there were unchecked warnings; re-run with -unchecked for details +one warning found List((a,0), (b,1), (c,2)) List((a,0), (b,1), (c,2)) List((a,0), (b,1), (c,2)) diff --git a/test/files/run/withIndex.scala b/test/files/run/withIndex.scala index fd79cd808a..d06dde89f0 100644 --- a/test/files/run/withIndex.scala +++ b/test/files/run/withIndex.scala @@ -9,7 +9,12 @@ object Test { Console.println(lst.zipWithIndex.toList) Console.println(itr.zipWithIndex.toList) Console.println(str.zipWithIndex.toList) - assert(ary.zipWithIndex.isInstanceOf[Array[Pair[String,Int]]]) + assert { + ary.zipWithIndex match { + case _: Array[Pair[String,Int]] => true + case _ => false + } + } val emptyArray = new Array[String](0) val emptyList: List[String] = Nil -- cgit v1.2.3