From 2fefb37220f82300e2aa44442f1a42261d65e359 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 3 Oct 2010 03:19:21 +0000 Subject: One last batch of test cleanups and I think I'l... One last batch of test cleanups and I think I'll call it a day. If you're worried I didn't leave any for anyone else, let me put your fears to rest. PLENTY left to sift through. No review. --- test/files/neg/t0513.check | 7 +++++++ test/files/neg/t0513.scala | 6 ++++++ test/files/neg/t2078.check | 4 ++++ test/files/neg/t2078.scala | 9 +++++++++ test/files/neg/t2180.check | 6 ++++++ test/files/neg/t2180.scala | 9 +++++++++ test/files/pos/t0625.scala | 8 ++++++++ test/pending/neg/bug1210.check | 7 ------- test/pending/neg/bug1210.scala | 10 ---------- test/pending/neg/bug1987.scala | 14 -------------- test/pending/neg/bug963.scala | 26 ++++++++++++++++++++++++++ test/pending/neg/t0513.scala | 6 ------ test/pending/neg/t0625.check | 7 ------- test/pending/neg/t0625.scala | 4 ---- test/pending/neg/t0653.check | 5 ----- test/pending/neg/t0653.scala | 28 ++++++++++++++++++++++++++-- test/pending/neg/t1038.check | 4 ---- test/pending/neg/t1038.scala | 7 ------- test/pending/neg/t1845.scala | 12 ------------ test/pending/neg/t2078.scala | 9 --------- test/pending/neg/t2079.scala | 25 ------------------------- test/pending/neg/t2180.scala | 31 ------------------------------- test/pending/pos/bug1987/bug1987a.scala | 7 +++++++ test/pending/pos/bug1987/bug1987b.scala | 10 ++++++++++ 24 files changed, 118 insertions(+), 143 deletions(-) create mode 100644 test/files/neg/t0513.check create mode 100644 test/files/neg/t0513.scala create mode 100644 test/files/neg/t2078.check create mode 100644 test/files/neg/t2078.scala create mode 100644 test/files/neg/t2180.check create mode 100644 test/files/neg/t2180.scala create mode 100644 test/files/pos/t0625.scala delete mode 100644 test/pending/neg/bug1210.check delete mode 100644 test/pending/neg/bug1210.scala delete mode 100644 test/pending/neg/bug1987.scala create mode 100644 test/pending/neg/bug963.scala delete mode 100644 test/pending/neg/t0513.scala delete mode 100644 test/pending/neg/t0625.check delete mode 100644 test/pending/neg/t0625.scala delete mode 100644 test/pending/neg/t0653.check delete mode 100644 test/pending/neg/t1038.check delete mode 100644 test/pending/neg/t1038.scala delete mode 100644 test/pending/neg/t1845.scala delete mode 100644 test/pending/neg/t2078.scala delete mode 100644 test/pending/neg/t2079.scala delete mode 100644 test/pending/neg/t2180.scala create mode 100644 test/pending/pos/bug1987/bug1987a.scala create mode 100644 test/pending/pos/bug1987/bug1987b.scala diff --git a/test/files/neg/t0513.check b/test/files/neg/t0513.check new file mode 100644 index 0000000000..edc0c9ab67 --- /dev/null +++ b/test/files/neg/t0513.check @@ -0,0 +1,7 @@ +t0513.scala:5: error: type arguments [Nothing,Int] do not conform to class Y's type parameter bounds [T1,T2 <: T1] + val test2 = Test[Y[Nothing, Int]] // No error + ^ +t0513.scala:5: error: type arguments [Nothing,Int] do not conform to class Y's type parameter bounds [T1,T2 <: T1] + val test2 = Test[Y[Nothing, Int]] // No error + ^ +two errors found diff --git a/test/files/neg/t0513.scala b/test/files/neg/t0513.scala new file mode 100644 index 0000000000..0193483cab --- /dev/null +++ b/test/files/neg/t0513.scala @@ -0,0 +1,6 @@ +object Test { + case class Y[T1, T2 <: T1]() + //val test = Y[Nothing, Int] // Compiler error + case class Test[T]() + val test2 = Test[Y[Nothing, Int]] // No error +} diff --git a/test/files/neg/t2078.check b/test/files/neg/t2078.check new file mode 100644 index 0000000000..1b79c19621 --- /dev/null +++ b/test/files/neg/t2078.check @@ -0,0 +1,4 @@ +t2078.scala:2: error: contravariant type S occurs in covariant position in type => java.lang.Object{val x: S} of value f + val f = new { val x = y } + ^ +one error found diff --git a/test/files/neg/t2078.scala b/test/files/neg/t2078.scala new file mode 100644 index 0000000000..a697afc646 --- /dev/null +++ b/test/files/neg/t2078.scala @@ -0,0 +1,9 @@ +class A[-S](y : S) { + val f = new { val x = y } +} + +object Test extends Application { + val a = new A(1) + val b = a : A[Nothing] + b.f.x +} diff --git a/test/files/neg/t2180.check b/test/files/neg/t2180.check new file mode 100644 index 0000000000..58eb05b6b6 --- /dev/null +++ b/test/files/neg/t2180.check @@ -0,0 +1,6 @@ +t2180.scala:3: error: type mismatch; + found : List[Any] + required: scala.List[Mxml] + children.toList.flatMap ( e => { + ^ +one error found diff --git a/test/files/neg/t2180.scala b/test/files/neg/t2180.scala new file mode 100644 index 0000000000..54a9e49c1c --- /dev/null +++ b/test/files/neg/t2180.scala @@ -0,0 +1,9 @@ +class Mxml { + private def processChildren( children:Seq[Any] ):List[Mxml] = { + children.toList.flatMap ( e => { + e match { + case s:scala.collection.Traversable[_] => s case a => List(a) + } + }) + } +} diff --git a/test/files/pos/t0625.scala b/test/files/pos/t0625.scala new file mode 100644 index 0000000000..5614542599 --- /dev/null +++ b/test/files/pos/t0625.scala @@ -0,0 +1,8 @@ +object Test { + def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t) + + def main(args: Array[String]): Unit = { + idMap(Some(5)) + idMap(Responder.constant(5)) + } +} diff --git a/test/pending/neg/bug1210.check b/test/pending/neg/bug1210.check deleted file mode 100644 index 4db920556f..0000000000 --- a/test/pending/neg/bug1210.check +++ /dev/null @@ -1,7 +0,0 @@ -bug1210.scala:13: error: illegal cyclic reference involving type Settings - val v: List[selfType] = f[selfType]((x: selfType) => x.v) - ^ -bug1210.scala:24: error: illegal cyclic reference involving type Settings - f[selfType](_.g) - ^ -two errors found diff --git a/test/pending/neg/bug1210.scala b/test/pending/neg/bug1210.scala deleted file mode 100644 index fc2c954ff2..0000000000 --- a/test/pending/neg/bug1210.scala +++ /dev/null @@ -1,10 +0,0 @@ -object Test { - def id[T](f: T => T): T = error("bla") - - abstract class M { self => - type Settings - type selfType = M {type Settings = self.Settings} - - val v: selfType = id[M.this.selfType](_.v) - } -} diff --git a/test/pending/neg/bug1987.scala b/test/pending/neg/bug1987.scala deleted file mode 100644 index d45f1b0f0d..0000000000 --- a/test/pending/neg/bug1987.scala +++ /dev/null @@ -1,14 +0,0 @@ - - -// Copyright Shunsuke Sogame 2008-2009. -// Distributed under the terms of an MIT-style license. - - -package object overloading { - def bar(f: (Int) => Unit): Unit = () - def bar(f: (Int, Int) => Unit): Unit = () -} - -class PackageObjectOverloadingTest { - overloading.bar( (i: Int) => () ) // doesn't compile. -} diff --git a/test/pending/neg/bug963.scala b/test/pending/neg/bug963.scala new file mode 100644 index 0000000000..430ef090e4 --- /dev/null +++ b/test/pending/neg/bug963.scala @@ -0,0 +1,26 @@ +// Soundness bug, at #963 and dup at #2079. +trait A { + type T + var v : T +} + +object B { + def f(x : { val y : A }) { x.y.v = x.y.v } + + var a : A = _ + var b : Boolean = false + def y : A = { + if(b) { + a = new A { type T = Int; var v = 1 } + a + } else { + a = new A { type T = String; var v = "" } + b = true + a + } + } +} + +object Test extends Application { + B.f(B) +} diff --git a/test/pending/neg/t0513.scala b/test/pending/neg/t0513.scala deleted file mode 100644 index 0082b0e563..0000000000 --- a/test/pending/neg/t0513.scala +++ /dev/null @@ -1,6 +0,0 @@ -object Test { - case class Y[T1, T2 <: T1] - //val test = Y[Nothing, Int] // Compiler error - case class Test[T] - val test2 = Test[Y[Nothing, Int]] // No error -} diff --git a/test/pending/neg/t0625.check b/test/pending/neg/t0625.check deleted file mode 100644 index 45a35eb157..0000000000 --- a/test/pending/neg/t0625.check +++ /dev/null @@ -1,7 +0,0 @@ - - -t0625.scala:3: error: inferred the kinds of the type arguments (Option[B],Int) do not conform to the expected kinds of the type parameters (type C,type T). -Option[B]'s type parameters do not match type C's expected parameters: class Option has one type parameter, but type C has one - idMap(Some(0)) - ^ -one error found diff --git a/test/pending/neg/t0625.scala b/test/pending/neg/t0625.scala deleted file mode 100644 index a44a04fd97..0000000000 --- a/test/pending/neg/t0625.scala +++ /dev/null @@ -1,4 +0,0 @@ -object Test { - def idMap[C[_],T](m: { def map[U](f: T => U): C[U] }): C[T] = m.map(t => t) - idMap(Some(0)) -} diff --git a/test/pending/neg/t0653.check b/test/pending/neg/t0653.check deleted file mode 100644 index cb5ca65b8e..0000000000 --- a/test/pending/neg/t0653.check +++ /dev/null @@ -1,5 +0,0 @@ -t0653.scala:5: error: inferred the kinds of the type arguments (InL[Nothing,Nothing]) do not conform to the expected kinds of the type parameters (type Op) in class Fix. -InL[Nothing,Nothing]'s type parameters do not match type Op's expected parameters: class InL has two type parameters, but type Op has one - val zero = new Fix(new InL) - ^ -one error found diff --git a/test/pending/neg/t0653.scala b/test/pending/neg/t0653.scala index 156aa2d701..48f39447ba 100644 --- a/test/pending/neg/t0653.scala +++ b/test/pending/neg/t0653.scala @@ -1,6 +1,30 @@ -class InL[A, B] +// What is this test in place to test for? +// +class One[A] +class Two[A, B] class Fix[Op[A]](x : Op[Fix[Op]]) class FixTest { - val zero = new Fix(new InL) + // works + // val zero = new Fix[One](new One) + + // don't work: + val two = new Fix(new Two) // this was what I found here + val zero = new Fix(new One) // this seems like something which could plausibly work + + // neg/t0653.scala:12: error: no type parameters for constructor Fix: (x: Op[Fix[Op[A]]])Fix[Op[A]] exist so that it can be applied to arguments (Two[Nothing,Nothing]) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : Two[Nothing,Nothing] + // required: ?Op[ Fix[?Op[ A ]] ] + // val two = new Fix(new Two) // this was what I found here + // ^ + // neg/t0653.scala:13: error: no type parameters for constructor Fix: (x: Op[Fix[Op[A]]])Fix[Op[A]] exist so that it can be applied to arguments (One[Nothing]) + // --- because --- + // argument expression's type is not compatible with formal parameter type; + // found : One[Nothing] + // required: ?Op[ Fix[?Op[ A ]] ] + // val zero = new Fix(new One) // this seems like something which could plausibly work + // ^ + // two errors found } diff --git a/test/pending/neg/t1038.check b/test/pending/neg/t1038.check deleted file mode 100644 index 3bfd479f42..0000000000 --- a/test/pending/neg/t1038.check +++ /dev/null @@ -1,4 +0,0 @@ -t1038.scala:4: error: wrong number of arguments for constructor X: (Int)X - val a = new X - ^ -one error found diff --git a/test/pending/neg/t1038.scala b/test/pending/neg/t1038.scala deleted file mode 100644 index 7157aafa06..0000000000 --- a/test/pending/neg/t1038.scala +++ /dev/null @@ -1,7 +0,0 @@ -class X(x : Int) - -object Y { - val a = new X - import a._ - implicit val b : Int = 1 -} diff --git a/test/pending/neg/t1845.scala b/test/pending/neg/t1845.scala deleted file mode 100644 index cfb28aa03c..0000000000 --- a/test/pending/neg/t1845.scala +++ /dev/null @@ -1,12 +0,0 @@ -// Compiling the attached code makes scalac give a NPE. - -import scala.util.parsing.combinator.syntactical.TokenParsers -import scala.util.parsing.combinator.lexical.StdLexical -import scala.util.parsing.syntax.StdTokens - -class MyTokenParsers extends TokenParsers { - import lexical._ - type Tokens = StdTokens - type Elem = lexical.Token - val lexical = new StdLexical -} diff --git a/test/pending/neg/t2078.scala b/test/pending/neg/t2078.scala deleted file mode 100644 index a697afc646..0000000000 --- a/test/pending/neg/t2078.scala +++ /dev/null @@ -1,9 +0,0 @@ -class A[-S](y : S) { - val f = new { val x = y } -} - -object Test extends Application { - val a = new A(1) - val b = a : A[Nothing] - b.f.x -} diff --git a/test/pending/neg/t2079.scala b/test/pending/neg/t2079.scala deleted file mode 100644 index a86674c7e0..0000000000 --- a/test/pending/neg/t2079.scala +++ /dev/null @@ -1,25 +0,0 @@ -trait A { - type T - var v : T -} - -object B { - def f(x : { val y : A }) { x.y.v = x.y.v } - - var a : A = _ - var b : Boolean = false - def y : A = { - if(b) { - a = new A { type T = Int; var v = 1 } - a - } else { - a = new A { type T = String; var v = "" } - b = true - a - } - } -} - -object Test extends Application { - B.f(B) -} diff --git a/test/pending/neg/t2180.scala b/test/pending/neg/t2180.scala deleted file mode 100644 index a8055bf77d..0000000000 --- a/test/pending/neg/t2180.scala +++ /dev/null @@ -1,31 +0,0 @@ - - -Given the following code (which is broken): - -class Mxml { - - private def processChildren( children:Seq[Any] ):List[Mxml] = { - - children.toList.flatMap ( e => { - - e match { - - case s:scala.collection.Traversable[_] => s case a => List(a) - - } - - }) - - } - -} - -I get the following error: - -Mxml.scala:5: error: could not find implicit value for parameter bf:scala.collection.generic.BuilderFactory[Any,List[Mxml],Sequence[Any]]. - - children.flatMap ( e => { - -I spent 4 hours failing before I figured out the problem. The return type was wrong. It should have been List[Any]. - -I have seen similar errors with map. My solution in the past has been to change it to a foldLeft because I have never been able to determine how to fix the problem until now. diff --git a/test/pending/pos/bug1987/bug1987a.scala b/test/pending/pos/bug1987/bug1987a.scala new file mode 100644 index 0000000000..7a62877ba0 --- /dev/null +++ b/test/pending/pos/bug1987/bug1987a.scala @@ -0,0 +1,7 @@ +package bug + +// goes with bug1987b.scala +package object packageb { + def func(a: Int) = () + def func(a: String) = () +} diff --git a/test/pending/pos/bug1987/bug1987b.scala b/test/pending/pos/bug1987/bug1987b.scala new file mode 100644 index 0000000000..875f5128f2 --- /dev/null +++ b/test/pending/pos/bug1987/bug1987b.scala @@ -0,0 +1,10 @@ +// compile with bug1987a.scala + +package bug.packageb +// Note that the overloading works if instead of being in the package we import it: +// replace the above line with import bug.packageb._ + +class Client { + val x = func(1) // doesn't compile: type mismatch; found: Int(1) required: String + val y = func("1") // compiles +} -- cgit v1.2.3