summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEugene Burmako <xeno.by@gmail.com>2012-04-14 21:11:37 +0200
committerEugene Burmako <xeno.by@gmail.com>2012-04-14 21:11:37 +0200
commit5e4c47f33b8e25feb59ab4599231b1b8d3150de8 (patch)
treeff2ded10d14c5a6e859ac216e60244029a17a505 /test
parent3a2901da406f2478b5634b0636e56de9c4cd676d (diff)
downloadscala-5e4c47f33b8e25feb59ab4599231b1b8d3150de8.tar.gz
scala-5e4c47f33b8e25feb59ab4599231b1b8d3150de8.tar.bz2
scala-5e4c47f33b8e25feb59ab4599231b1b8d3150de8.zip
implements reification of tough types
Diffstat (limited to 'test')
-rw-r--r--test/files/jvm/manifests.check56
-rw-r--r--test/files/jvm/manifests.check.temporarily.disabled55
-rw-r--r--test/files/jvm/manifests.scala (renamed from test/files/jvm/manifests.scala.temporarily.disabled)9
-rw-r--r--test/files/neg/t3507.check4
-rw-r--r--test/files/pos/implicits.scala (renamed from test/files/pos/implicits.scala.temporarily.disabled)0
-rw-r--r--test/files/pos/manifest1.scala (renamed from test/files/pos/manifest1.scala.temporarily.disabled)0
-rw-r--r--test/files/run/existentials3.check24
-rw-r--r--test/files/run/existentials3.check.temporarily.disabled22
-rw-r--r--test/files/run/existentials3.scala (renamed from test/files/run/existentials3.scala.temporarily.disabled)20
-rw-r--r--test/files/run/t1195.check6
-rw-r--r--test/files/run/t1195.check.temporarily.disabled6
-rw-r--r--test/files/run/t1195.scala (renamed from test/files/run/t1195.scala.temporarily.disabled)4
-rw-r--r--test/files/run/t3507.check1
-rw-r--r--test/files/run/t3507.scala (renamed from test/files/neg/t3507.scala)6
-rw-r--r--test/files/run/t4110.check2
-rw-r--r--test/files/run/t4110.check.temporarily.disabled2
-rw-r--r--test/files/run/t4110.scala (renamed from test/files/run/t4110.scala.temporarily.disabled)0
-rw-r--r--test/files/run/treePrint.check (renamed from test/files/run/treePrint.check.temporarily.disabled)0
-rw-r--r--test/files/run/treePrint.scala (renamed from test/files/run/treePrint.scala.temporarily.disabled)11
19 files changed, 119 insertions, 109 deletions
diff --git a/test/files/jvm/manifests.check b/test/files/jvm/manifests.check
new file mode 100644
index 0000000000..be8ec2bb5b
--- /dev/null
+++ b/test/files/jvm/manifests.check
@@ -0,0 +1,56 @@
+x=(), m=ConcreteTypeTag[Unit], k=TypeRef, s=class Unit
+x=true, m=ConcreteTypeTag[Boolean], k=TypeRef, s=class Boolean
+x=a, m=ConcreteTypeTag[Char], k=TypeRef, s=class Char
+x=1, m=ConcreteTypeTag[Int], k=TypeRef, s=class Int
+x=abc, m=ConcreteTypeTag[String], k=TypeRef, s=class String
+x='abc, m=ConcreteTypeTag[Symbol], k=TypeRef, s=class Symbol
+
+x=List(()), m=ConcreteTypeTag[List[Unit]], k=TypeRef, s=class List
+x=List(true), m=ConcreteTypeTag[List[Boolean]], k=TypeRef, s=class List
+x=List(1), m=ConcreteTypeTag[List[Int]], k=TypeRef, s=class List
+x=List(abc), m=ConcreteTypeTag[List[String]], k=TypeRef, s=class List
+x=List('abc), m=ConcreteTypeTag[List[Symbol]], k=TypeRef, s=class List
+
+x=[Z, m=ConcreteTypeTag[Array[Boolean]], k=TypeRef, s=class Array
+x=[C, m=ConcreteTypeTag[Array[Char]], k=TypeRef, s=class Array
+x=[I, m=ConcreteTypeTag[Array[Int]], k=TypeRef, s=class Array
+x=[Ljava.lang.String;, m=ConcreteTypeTag[Array[String]], k=TypeRef, s=class Array
+x=[Lscala.Symbol;, m=ConcreteTypeTag[Array[Symbol]], k=TypeRef, s=class Array
+
+x=((),()), m=ConcreteTypeTag[(Unit, Unit)], k=TypeRef, s=class Tuple2
+x=(true,false), m=ConcreteTypeTag[(Boolean, Boolean)], k=TypeRef, s=class Tuple2
+x=(1,2), m=ConcreteTypeTag[(Int, Int)], k=TypeRef, s=class Tuple2
+x=(abc,xyz), m=ConcreteTypeTag[(String, String)], k=TypeRef, s=class Tuple2
+x=('abc,'xyz), m=ConcreteTypeTag[(Symbol, Symbol)], k=TypeRef, s=class Tuple2
+
+
+x=Foo, m=ConcreteTypeTag[Foo[Int]], k=TypeRef, s=class Foo
+x=Foo, m=ConcreteTypeTag[Foo[List[Int]]], k=TypeRef, s=class Foo
+x=Foo, m=ConcreteTypeTag[Foo[Foo[Int]]], k=TypeRef, s=class Foo
+x=Foo, m=ConcreteTypeTag[Foo[List[Foo[Int]]]], k=TypeRef, s=class Foo
+
+x=Test1$$anon$1, m=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
+x=Test1$$anon$2, m=ConcreteTypeTag[Bar[String]], k=RefinedType, s=<local Test1>
+
+()=()
+true=true
+a=a
+1=1
+'abc='abc
+
+List(())=List(())
+List(true)=List(true)
+List('abc)=List('abc)
+
+Array()=Array()
+Array(true)=Array(true)
+Array(a)=Array(a)
+Array(1)=Array(1)
+
+((),())=((),())
+(true,false)=(true,false)
+
+List(List(1), List(2))=List(List(1), List(2))
+
+Array(Array(1), Array(2))=Array(Array(1), Array(2))
+
diff --git a/test/files/jvm/manifests.check.temporarily.disabled b/test/files/jvm/manifests.check.temporarily.disabled
deleted file mode 100644
index 54f504b929..0000000000
--- a/test/files/jvm/manifests.check.temporarily.disabled
+++ /dev/null
@@ -1,55 +0,0 @@
-x=(), m=Unit
-x=true, m=Boolean
-x=a, m=Char
-x=1, m=Int
-x=abc, m=java.lang.String
-x='abc, m=scala.Symbol
-
-x=List(()), m=scala.collection.immutable.List[Unit]
-x=List(true), m=scala.collection.immutable.List[Boolean]
-x=List(1), m=scala.collection.immutable.List[Int]
-x=List(abc), m=scala.collection.immutable.List[java.lang.String]
-x=List('abc), m=scala.collection.immutable.List[scala.Symbol]
-
-x=[Z, m=Array[Boolean]
-x=[C, m=Array[Char]
-x=[I, m=Array[Int]
-x=[Ljava.lang.String;, m=Array[java.lang.String]
-x=[Lscala.Symbol;, m=Array[scala.Symbol]
-
-x=((),()), m=scala.Tuple2[Unit, Unit]
-x=(true,false), m=scala.Tuple2[Boolean, Boolean]
-x=(1,2), m=scala.Tuple2[Int, Int]
-x=(abc,xyz), m=scala.Tuple2[java.lang.String, java.lang.String]
-x=('abc,'xyz), m=scala.Tuple2[scala.Symbol, scala.Symbol]
-
-
-x=Foo, m=Foo[Int]
-x=Foo, m=Foo[scala.collection.immutable.List[Int]]
-x=Foo, m=Foo[Foo[Int]]
-x=Foo, m=Foo[scala.collection.immutable.List[Foo[Int]]]
-
-x=Test1$$anon$1, m=Object with Bar[java.lang.String]
-
-()=()
-true=true
-a=a
-1=1
-'abc='abc
-
-List(())=List(())
-List(true)=List(true)
-List('abc)=List('abc)
-
-Array()=Array()
-Array(true)=Array(true)
-Array(a)=Array(a)
-Array(1)=Array(1)
-
-((),())=((),())
-(true,false)=(true,false)
-
-List(List(1), List(2))=List(List(1), List(2))
-
-Array(Array(1), Array(2))=Array(Array(1), Array(2))
-
diff --git a/test/files/jvm/manifests.scala.temporarily.disabled b/test/files/jvm/manifests.scala
index 241966fd9d..935427f5d4 100644
--- a/test/files/jvm/manifests.scala.temporarily.disabled
+++ b/test/files/jvm/manifests.scala
@@ -50,7 +50,8 @@ object Test1 extends TestUtil {
print(new Foo(List(new Foo(2))))
println()
- print(new Bar[String] { def f = "abc" })
+ print(new Bar[String] { def f = "abc" });
+ {print(new Bar[String] { def f = "abc" })}
println()
}
@@ -102,8 +103,10 @@ trait TestUtil {
}
import scala.reflect._
def print[T](x: T)(implicit m: Manifest[T]) {
- val m1: Manifest[T] = read(write(m))
+ // manifests are no longer serializable
+// val m1: Manifest[T] = read(write(m))
+ val m1: Manifest[T] = m
val x1 = x.toString.replaceAll("@[0-9a-z]+$", "")
- println("x="+x1+", m="+m1)
+ println("x="+x1+", m="+m1+", k="+m1.tpe.kind+", s="+m1.sym.toString)
}
}
diff --git a/test/files/neg/t3507.check b/test/files/neg/t3507.check
deleted file mode 100644
index 71bf295039..0000000000
--- a/test/files/neg/t3507.check
+++ /dev/null
@@ -1,4 +0,0 @@
-t3507.scala:13: error: No ConcreteTypeTag available for _1.b.c.type
- mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier
- ^
-one error found
diff --git a/test/files/pos/implicits.scala.temporarily.disabled b/test/files/pos/implicits.scala
index 2c01dd0ba8..2c01dd0ba8 100644
--- a/test/files/pos/implicits.scala.temporarily.disabled
+++ b/test/files/pos/implicits.scala
diff --git a/test/files/pos/manifest1.scala.temporarily.disabled b/test/files/pos/manifest1.scala
index 8901aa7437..8901aa7437 100644
--- a/test/files/pos/manifest1.scala.temporarily.disabled
+++ b/test/files/pos/manifest1.scala
diff --git a/test/files/run/existentials3.check b/test/files/run/existentials3.check
new file mode 100644
index 0000000000..8227d77909
--- /dev/null
+++ b/test/files/run/existentials3.check
@@ -0,0 +1,24 @@
+ConcreteTypeTag[Bar.type], t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
+ConcreteTypeTag[Bar], t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+ConcreteTypeTag[Test.ToS], t=RefinedType, s=f3
+ConcreteTypeTag[Test.ToS], t=RefinedType, s=f4
+ConcreteTypeTag[Test.ToS], t=RefinedType, s=f5
+ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
+ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
+ConcreteTypeTag[$anon], t=TypeRef, s= <: B with Test.ToS
+ConcreteTypeTag[$anon], t=TypeRef, s= <: B with A with Test.ToS
+ConcreteTypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List
+ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List
+ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List
+ConcreteTypeTag[Bar.type], t=TypeRef, s= <: scala.runtime.AbstractFunction0[Bar] with Serializable{case def unapply(x$0: Bar): Boolean} with Singleton
+ConcreteTypeTag[Bar], t=TypeRef, s= <: Test.ToS with Product with Serializable{def copy(): Bar}
+ConcreteTypeTag[Test.ToS], t=RefinedType, s=g3
+ConcreteTypeTag[Test.ToS], t=RefinedType, s=g4
+ConcreteTypeTag[Test.ToS], t=RefinedType, s=g5
+ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
+ConcreteTypeTag[() => Test.ToS], t=TypeRef, s=class Function0
+ConcreteTypeTag[$anon], t=TypeRef, s= <: B with Test.ToS
+ConcreteTypeTag[$anon], t=TypeRef, s= <: B with A with Test.ToS
+ConcreteTypeTag[List[Object{type T1}#T1]], t=TypeRef, s=class List
+ConcreteTypeTag[List[Seq[Int]]], t=TypeRef, s=class List
+ConcreteTypeTag[List[Seq[U forSome { type U <: Int }]]], t=TypeRef, s=class List
diff --git a/test/files/run/existentials3.check.temporarily.disabled b/test/files/run/existentials3.check.temporarily.disabled
deleted file mode 100644
index 36a458dacc..0000000000
--- a/test/files/run/existentials3.check.temporarily.disabled
+++ /dev/null
@@ -1,22 +0,0 @@
-_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
-_ <: Object with Test$ToS with scala.Product with scala.Serializable
-Object with Test$ToS
-Object with Test$ToS
-Object with Test$ToS
-scala.Function0[Object with Test$ToS]
-scala.Function0[Object with Test$ToS]
-_ <: Object with _ <: Object with Object with Test$ToS
-_ <: Object with _ <: Object with _ <: Object with Test$ToS
-scala.collection.immutable.List[Object with scala.collection.Seq[Int]]
-scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]]
-_ <: scala.runtime.AbstractFunction0[_ <: Object with Test$ToS with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
-_ <: Object with Test$ToS with scala.Product with scala.Serializable
-Object with Test$ToS
-Object with Test$ToS
-Object with Test$ToS
-scala.Function0[Object with Test$ToS]
-scala.Function0[Object with Test$ToS]
-_ <: Object with _ <: Object with Object with Test$ToS
-_ <: Object with _ <: Object with _ <: Object with Test$ToS
-scala.collection.immutable.List[Object with scala.collection.Seq[Int]]
-scala.collection.immutable.List[Object with scala.collection.Seq[_ <: Int]]
diff --git a/test/files/run/existentials3.scala.temporarily.disabled b/test/files/run/existentials3.scala
index bb80d366cc..d6d5612687 100644
--- a/test/files/run/existentials3.scala.temporarily.disabled
+++ b/test/files/run/existentials3.scala
@@ -11,11 +11,11 @@ object Test {
def f8 = { trait A ; trait B extends A ; class C extends B with ToS; new C { } }
def f9 = { trait A ; trait B ; class C extends B with A with ToS; new C { } }
-
+
def f10 = { class A { type T1 } ; List[A#T1]() }
def f11 = { abstract class A extends Seq[Int] ; List[A]() }
def f12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() }
-
+
val g1 = { case class Bar() extends ToS; Bar }
val g2 = { case class Bar() extends ToS; Bar() }
val g3 = { class Bar() extends ToS; object Bar extends ToS; Bar }
@@ -30,10 +30,16 @@ object Test {
val g10 = { class A { type T1 } ; List[A#T1]() }
val g11 = { abstract class A extends Seq[Int] ; List[A]() }
val g12 = { abstract class A extends Seq[U forSome { type U <: Int }] ; List[A]() }
-
- def m[T: Manifest](x: T) = println(manifest[T])
-
+
+ def printTag(t: TypeTag[_]) = {
+ val s = if (t.sym.isFreeType) t.sym.typeSignature.toString else t.sym.toString
+ println("%s, t=%s, s=%s".format(t, t.tpe.kind, s))
+ }
+ def m[T: ConcreteTypeTag](x: T) = printTag(concreteTypeTag[T])
+ def m2[T: TypeTag](x: T) = printTag(typeTag[T])
+
// manifests don't work for f10/g10
+ // oh, they do now :)
def main(args: Array[String]): Unit = {
m(f1)
m(f2)
@@ -44,7 +50,7 @@ object Test {
m(f7)
m(f8)
m(f9)
- // m(f10)
+ m2(f10)
m(f11)
m(f12)
m(g1)
@@ -56,7 +62,7 @@ object Test {
m(g7)
m(g8)
m(g9)
- // m(g10)
+ m2(g10)
m(g11)
m(g12)
}
diff --git a/test/files/run/t1195.check b/test/files/run/t1195.check
new file mode 100644
index 0000000000..554e3fd03d
--- /dev/null
+++ b/test/files/run/t1195.check
@@ -0,0 +1,6 @@
+ConcreteTypeTag[Bar.type], underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
+ConcreteTypeTag[Bar], underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
+ConcreteTypeTag[Product with Serializable], underlying = Product with Serializable
+ConcreteTypeTag[Bar.type], underlying = <: scala.runtime.AbstractFunction1[Int,Bar] with Serializable{case def unapply(x$0: Bar): Option[Int]} with Singleton
+ConcreteTypeTag[Bar], underlying = <: Product with Serializable{val x: Int; def copy(x: Int): Bar; def copy$default$1: Int; def _1: Int}
+ConcreteTypeTag[Product with Serializable], underlying = Product with Serializable
diff --git a/test/files/run/t1195.check.temporarily.disabled b/test/files/run/t1195.check.temporarily.disabled
deleted file mode 100644
index d023bc91f7..0000000000
--- a/test/files/run/t1195.check.temporarily.disabled
+++ /dev/null
@@ -1,6 +0,0 @@
-_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
-_ <: Object with scala.Product with scala.Serializable
-Object with scala.Product with scala.Serializable
-_ <: scala.runtime.AbstractFunction1[Int, _ <: Object with scala.Product with scala.Serializable] with scala.Serializable with java.lang.Object
-_ <: Object with scala.Product with scala.Serializable
-Object with scala.Product with scala.Serializable
diff --git a/test/files/run/t1195.scala.temporarily.disabled b/test/files/run/t1195.scala
index 81ef5bdb0e..93b1dcbd07 100644
--- a/test/files/run/t1195.scala.temporarily.disabled
+++ b/test/files/run/t1195.scala
@@ -6,8 +6,8 @@ object Test {
val f1 = f()
val g1 = g()
val h1 = h()
-
- def m[T: Manifest](x: T) = println(manifest[T])
+
+ def m[T: Manifest](x: T) = println(manifest[T] + ", underlying = " + manifest[T].sym.typeSignature)
def main(args: Array[String]): Unit = {
m(f)
diff --git a/test/files/run/t3507.check b/test/files/run/t3507.check
new file mode 100644
index 0000000000..50ab029592
--- /dev/null
+++ b/test/files/run/t3507.check
@@ -0,0 +1 @@
+ConcreteTypeTag[_1.type#b.c.type]
diff --git a/test/files/neg/t3507.scala b/test/files/run/t3507.scala
index 32688d3934..3cdd40a881 100644
--- a/test/files/neg/t3507.scala
+++ b/test/files/run/t3507.scala
@@ -5,11 +5,11 @@ class A {
def m = b.c
}
-object Test {
+object Test extends App {
var a: A = new A // mutable
val c /*: object _1.b.c forSome { val _1: A } */ = a.m // widening using existential
-
- def mani[T: Manifest](x: T) = ()
+
+ def mani[T: Manifest](x: T) = println(manifest[T])
mani/*[object _1.b.c]*/(c) // kaboom in manifestOfType / TreeGen.mkAttributedQualifier
// --> _1 is not in scope here
} \ No newline at end of file
diff --git a/test/files/run/t4110.check b/test/files/run/t4110.check
new file mode 100644
index 0000000000..28f220e1fe
--- /dev/null
+++ b/test/files/run/t4110.check
@@ -0,0 +1,2 @@
+ConcreteTypeTag[Test.A with Test.B]
+ConcreteTypeTag[Test.A with Test.B]
diff --git a/test/files/run/t4110.check.temporarily.disabled b/test/files/run/t4110.check.temporarily.disabled
deleted file mode 100644
index 8b005989de..0000000000
--- a/test/files/run/t4110.check.temporarily.disabled
+++ /dev/null
@@ -1,2 +0,0 @@
-Object with Test$A with Test$B
-Object with Test$A with Test$B
diff --git a/test/files/run/t4110.scala.temporarily.disabled b/test/files/run/t4110.scala
index 4bd377b73e..4bd377b73e 100644
--- a/test/files/run/t4110.scala.temporarily.disabled
+++ b/test/files/run/t4110.scala
diff --git a/test/files/run/treePrint.check.temporarily.disabled b/test/files/run/treePrint.check
index 3360815ac1..3360815ac1 100644
--- a/test/files/run/treePrint.check.temporarily.disabled
+++ b/test/files/run/treePrint.check
diff --git a/test/files/run/treePrint.scala.temporarily.disabled b/test/files/run/treePrint.scala
index e0332a705f..4a80e2824d 100644
--- a/test/files/run/treePrint.scala.temporarily.disabled
+++ b/test/files/run/treePrint.scala
@@ -4,7 +4,7 @@ object Test {
import scala.tools.nsc._
import interpreter._
import java.io.{ OutputStream, BufferedReader, StringReader, PrintWriter, Writer, OutputStreamWriter}
-
+
val code = """
def foo = {
var q: Boolean = false
@@ -22,11 +22,11 @@ object Test {
else 20
}
else 30
-
+
(x == 5) || !q || true
}
- """
-
+ """
+
class NullOutputStream extends OutputStream { def write(b: Int) { } }
def main(args: Array[String]) {
@@ -35,7 +35,8 @@ object Test {
settings.Ycompacttrees.value = true
val intp = new IMain(settings, new PrintWriter(new NullOutputStream))
- val power = new Power(intp, new ReplVals { })
+ val vals = new ReplVals { }
+ val power = new Power(intp, vals)
intp.interpret("""def initialize = "Have to interpret something or we get errors." """)
power trees code foreach println
}