From 622656dfc87100bc94a37f3b244955c96d526023 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Thu, 23 Feb 2012 10:59:55 -0800 Subject: Moved and edited tests. Remove obsolete, move passing pending -> files, update those-kinds-are-high with some new info, added a couple new ones to pending. --- test/files/pos/local-objects.scala | 9 ++++++ test/files/pos/package-case.scala | 4 +++ test/files/pos/t1957.scala | 38 ++++++++++++++++++++++++ test/files/pos/t1987b/a.scala | 7 +++++ test/files/pos/t1987b/b.scala | 10 +++++++ test/files/pos/t2194.scala | 8 +++++ test/pending/pos/inference.scala | 39 +++++++++++++++++++++++++ test/pending/pos/local-objects.scala | 9 ------ test/pending/pos/nothing.scala | 24 +++++++++++++++ test/pending/pos/package-case.scala | 4 --- test/pending/pos/t1380/gnujaxp.jar.desired.sha1 | 1 - test/pending/pos/t1380/hallo.scala | 3 -- test/pending/pos/t1957.scala | 38 ------------------------ test/pending/pos/t1987/a.scala | 7 ----- test/pending/pos/t1987/b.scala | 10 ------- test/pending/pos/t2194.scala | 8 ----- test/pending/pos/those-kinds-are-high.scala | 18 +++++++++++- 17 files changed, 156 insertions(+), 81 deletions(-) create mode 100644 test/files/pos/local-objects.scala create mode 100644 test/files/pos/package-case.scala create mode 100644 test/files/pos/t1957.scala create mode 100644 test/files/pos/t1987b/a.scala create mode 100644 test/files/pos/t1987b/b.scala create mode 100644 test/files/pos/t2194.scala create mode 100644 test/pending/pos/inference.scala delete mode 100644 test/pending/pos/local-objects.scala create mode 100644 test/pending/pos/nothing.scala delete mode 100644 test/pending/pos/package-case.scala delete mode 100644 test/pending/pos/t1380/gnujaxp.jar.desired.sha1 delete mode 100644 test/pending/pos/t1380/hallo.scala delete mode 100644 test/pending/pos/t1957.scala delete mode 100644 test/pending/pos/t1987/a.scala delete mode 100644 test/pending/pos/t1987/b.scala delete mode 100644 test/pending/pos/t2194.scala (limited to 'test') diff --git a/test/files/pos/local-objects.scala b/test/files/pos/local-objects.scala new file mode 100644 index 0000000000..ed7c50ead9 --- /dev/null +++ b/test/files/pos/local-objects.scala @@ -0,0 +1,9 @@ + + +object Main { + val x = { + object Boo + Boo + } +} + diff --git a/test/files/pos/package-case.scala b/test/files/pos/package-case.scala new file mode 100644 index 0000000000..906f1eb3f2 --- /dev/null +++ b/test/files/pos/package-case.scala @@ -0,0 +1,4 @@ +// a.scala +// Sat Jul 16 00:34:36 EDT 2011 + +package object io { case class TextReader() } diff --git a/test/files/pos/t1957.scala b/test/files/pos/t1957.scala new file mode 100644 index 0000000000..f80cf730ed --- /dev/null +++ b/test/files/pos/t1957.scala @@ -0,0 +1,38 @@ +object Test { + abstract class Settings {} + + abstract class Grist + { self => + type settingsType <: Settings + type moduleType <: Module {type settingsType = self.settingsType} + val module: moduleType + } + + abstract class Tool + { self => + type settingsType <: Settings + type moduleType = Module { type settingsType = self.settingsType } + type gristType = Grist { type moduleType <: self.moduleType; type settingsType <: self.settingsType } + + def inputGrist: List[gristType] + } + + abstract class Module + { self => + type settingsType <: Settings + final type commonModuleType = Module {type settingsType = self.settingsType} + type selfType >: self.type <: commonModuleType + + // BTW: if we use the commented out type declarations, the code compiles successfully + // type gristType = Grist {type settingsType <: self.settingsType; type moduleType <: commonModuleType } + + val tools: List[Tool {type settingsType = self.settingsType}] + + protected def f: List[commonModuleType] = + { + val inputGrists = tools.flatMap(_.inputGrist) // val inputGrists: List[gristType] = + inputGrists.map(_.module) + } + + } +} diff --git a/test/files/pos/t1987b/a.scala b/test/files/pos/t1987b/a.scala new file mode 100644 index 0000000000..ff27044b69 --- /dev/null +++ b/test/files/pos/t1987b/a.scala @@ -0,0 +1,7 @@ +package bug + +// goes with t1987b.scala +package object packageb { + def func(a: Int) = () + def func(a: String) = () +} diff --git a/test/files/pos/t1987b/b.scala b/test/files/pos/t1987b/b.scala new file mode 100644 index 0000000000..a469ca6ea8 --- /dev/null +++ b/test/files/pos/t1987b/b.scala @@ -0,0 +1,10 @@ +// compile with t1987a.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 +} diff --git a/test/files/pos/t2194.scala b/test/files/pos/t2194.scala new file mode 100644 index 0000000000..e87be509d1 --- /dev/null +++ b/test/files/pos/t2194.scala @@ -0,0 +1,8 @@ +// tricky to do differently? +class C + +object Test { + def f = { object o extends C; o} + val y: C = f + val x = f +} diff --git a/test/pending/pos/inference.scala b/test/pending/pos/inference.scala new file mode 100644 index 0000000000..d28d003435 --- /dev/null +++ b/test/pending/pos/inference.scala @@ -0,0 +1,39 @@ +// inference illuminator +object Test { + class D1[T1 : Manifest, T2 <: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) } + class D2[T1 : Manifest, T2 >: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) } + class D3[+T1 : Manifest, T2 <: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) } + class D4[-T1 : Manifest, T2 >: T1 : Manifest](x: T1) { println(manifest[(T1, T2)]) } + + class E1[T1 : Manifest, T2 <: T1 : Manifest](x: D1[T1, T2]) { println(manifest[(T1, T2)]) } + class E2[T1 : Manifest, T2 >: T1 : Manifest](x: D2[T1, T2]) { println(manifest[(T1, T2)]) } + class E3[+T1 : Manifest, T2 <: T1 : Manifest](x: D3[T1, T2]) { println(manifest[(T1, T2)]) } + class E4[-T1 : Manifest, T2 >: T1 : Manifest](x: D4[T1, T2]) { println(manifest[(T1, T2)]) } + + def main(args: Array[String]): Unit = { + // WHY YOU NO LIKE NOTHING SO MUCH SCALAC? + val d1 = new D1(5) + val d2 = new D2(5) + val d3 = new D3(5) + val d4 = new D4(5) + + new E1(d1) // fails + new E2(d2) + new E3(d3) // fails + new E4(d4) + } + // found : Test.D1[Int,Nothing] + // required: Test.D1[Int,T2] + // Note: Nothing <: T2, but class D1 is invariant in type T2. + // You may wish to define T2 as +T2 instead. (SLS 4.5) + // new E1(d1) + // ^ + // test/pending/pos/inference.scala:22: error: type mismatch; + // found : Test.D3[Int,Nothing] + // required: Test.D3[Int,T2] + // Note: Nothing <: T2, but class D3 is invariant in type T2. + // You may wish to define T2 as +T2 instead. (SLS 4.5) + // new E3(d3) + // ^ + // two errors found +} diff --git a/test/pending/pos/local-objects.scala b/test/pending/pos/local-objects.scala deleted file mode 100644 index ed7c50ead9..0000000000 --- a/test/pending/pos/local-objects.scala +++ /dev/null @@ -1,9 +0,0 @@ - - -object Main { - val x = { - object Boo - Boo - } -} - diff --git a/test/pending/pos/nothing.scala b/test/pending/pos/nothing.scala new file mode 100644 index 0000000000..f76017fb16 --- /dev/null +++ b/test/pending/pos/nothing.scala @@ -0,0 +1,24 @@ +// More shoddy treatment for nothing. +class A { + class Q3A[+T1, T2 <: T1](x: T1) + class Q3B[+T1, T2 <: T1](x: Q3A[T1, T2]) + + val x1 = new Q3B(new Q3A("a")) + val x2 = new Q3B(new Q3A[String, Nothing]("a")) + val x3 = new Q3B(new Q3A[String, Null]("a")) + // test/pending/pos/nothing.scala:5: error: type mismatch; + // found : A.this.Q3A[String,Nothing] + // required: A.this.Q3A[String,T2] + // Note: Nothing <: T2, but class Q3A is invariant in type T2. + // You may wish to define T2 as +T2 instead. (SLS 4.5) + // val x1 = new Q3B(new Q3A("a")) + // ^ + // test/pending/pos/nothing.scala:6: error: type mismatch; + // found : A.this.Q3A[String,Nothing] + // required: A.this.Q3A[String,T2] + // Note: Nothing <: T2, but class Q3A is invariant in type T2. + // You may wish to define T2 as +T2 instead. (SLS 4.5) + // val x2 = new Q3B(new Q3A[String, Nothing]("a")) + // ^ + // two errors found +} diff --git a/test/pending/pos/package-case.scala b/test/pending/pos/package-case.scala deleted file mode 100644 index 906f1eb3f2..0000000000 --- a/test/pending/pos/package-case.scala +++ /dev/null @@ -1,4 +0,0 @@ -// a.scala -// Sat Jul 16 00:34:36 EDT 2011 - -package object io { case class TextReader() } diff --git a/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 b/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 deleted file mode 100644 index c155c2aaa2..0000000000 --- a/test/pending/pos/t1380/gnujaxp.jar.desired.sha1 +++ /dev/null @@ -1 +0,0 @@ -ee000286d00c5209d5644462c1cfea87fc8b1342 ?gnujaxp.jar diff --git a/test/pending/pos/t1380/hallo.scala b/test/pending/pos/t1380/hallo.scala deleted file mode 100644 index bb8fff2333..0000000000 --- a/test/pending/pos/t1380/hallo.scala +++ /dev/null @@ -1,3 +0,0 @@ -object hallo { - def main(args:Array[String]) = println("hallo") -} diff --git a/test/pending/pos/t1957.scala b/test/pending/pos/t1957.scala deleted file mode 100644 index f80cf730ed..0000000000 --- a/test/pending/pos/t1957.scala +++ /dev/null @@ -1,38 +0,0 @@ -object Test { - abstract class Settings {} - - abstract class Grist - { self => - type settingsType <: Settings - type moduleType <: Module {type settingsType = self.settingsType} - val module: moduleType - } - - abstract class Tool - { self => - type settingsType <: Settings - type moduleType = Module { type settingsType = self.settingsType } - type gristType = Grist { type moduleType <: self.moduleType; type settingsType <: self.settingsType } - - def inputGrist: List[gristType] - } - - abstract class Module - { self => - type settingsType <: Settings - final type commonModuleType = Module {type settingsType = self.settingsType} - type selfType >: self.type <: commonModuleType - - // BTW: if we use the commented out type declarations, the code compiles successfully - // type gristType = Grist {type settingsType <: self.settingsType; type moduleType <: commonModuleType } - - val tools: List[Tool {type settingsType = self.settingsType}] - - protected def f: List[commonModuleType] = - { - val inputGrists = tools.flatMap(_.inputGrist) // val inputGrists: List[gristType] = - inputGrists.map(_.module) - } - - } -} diff --git a/test/pending/pos/t1987/a.scala b/test/pending/pos/t1987/a.scala deleted file mode 100644 index ff27044b69..0000000000 --- a/test/pending/pos/t1987/a.scala +++ /dev/null @@ -1,7 +0,0 @@ -package bug - -// goes with t1987b.scala -package object packageb { - def func(a: Int) = () - def func(a: String) = () -} diff --git a/test/pending/pos/t1987/b.scala b/test/pending/pos/t1987/b.scala deleted file mode 100644 index a469ca6ea8..0000000000 --- a/test/pending/pos/t1987/b.scala +++ /dev/null @@ -1,10 +0,0 @@ -// compile with t1987a.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 -} diff --git a/test/pending/pos/t2194.scala b/test/pending/pos/t2194.scala deleted file mode 100644 index e87be509d1..0000000000 --- a/test/pending/pos/t2194.scala +++ /dev/null @@ -1,8 +0,0 @@ -// tricky to do differently? -class C - -object Test { - def f = { object o extends C; o} - val y: C = f - val x = f -} diff --git a/test/pending/pos/those-kinds-are-high.scala b/test/pending/pos/those-kinds-are-high.scala index 3012e72d7e..434e64cefb 100644 --- a/test/pending/pos/those-kinds-are-high.scala +++ b/test/pending/pos/those-kinds-are-high.scala @@ -27,11 +27,27 @@ class A { // // List[Container[String] with Template[Container[Any] with Template[Container[Any] with Template[Any]]] // + // *** Update 2/24/2012 + // + // Hey, now there are polytypes in the inferred type. + // Not sure if that is progress or regress. + // + // test/pending/pos/those-kinds-are-high.scala:36: error: type mismatch; + // found : C1[String] + // required: ScalaObject with Container[String] with Template[ScalaObject with Container with Template[ScalaObject with Container with Template[[X]Container[X]]]] + // def fFail = List(new C1[String], new C2[String]) + // ^ + // test/pending/pos/those-kinds-are-high.scala:36: error: type mismatch; + // found : C2[String] + // required: ScalaObject with Container[String] with Template[ScalaObject with Container with Template[ScalaObject with Container with Template[[X]Container[X]]]] + // def fFail = List(new C1[String], new C2[String]) + // ^ + // two errors found /** Working version explicitly typed. */ def fExplicit = List[Template[Container] with Container[String]](new C1[String], new C2[String]) // nope - // def fFail = List(new C1[String], new C2[String]) + def fFail = List(new C1[String], new C2[String]) } -- cgit v1.2.3