summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t0764.check7
-rw-r--r--test/files/neg/t0764.scala45
-rw-r--r--test/files/neg/t0764b.check47
-rw-r--r--test/files/neg/t0764b.scala (renamed from test/files/pos/t0764b.scala)2
-rw-r--r--test/files/neg/t8104/Test_2.scala2
-rw-r--r--test/files/neg/t8177a.check6
-rw-r--r--test/files/neg/t8177a.scala6
-rw-r--r--test/files/pos/t0764.scala27
-rw-r--r--test/files/pos/t1786-cycle.scala57
-rw-r--r--test/files/pos/t8177h.scala5
-rw-r--r--test/files/run/t6992.check1
-rw-r--r--test/files/run/t6992/Test_2.scala4
-rw-r--r--test/files/run/t8104.check3
-rw-r--r--test/files/run/t8104/Test_2.scala5
-rw-r--r--test/files/run/t8153.check1
-rw-r--r--test/files/run/t8153.scala14
-rw-r--r--test/files/run/t8280.check9
-rw-r--r--test/files/run/t8280.scala82
18 files changed, 292 insertions, 31 deletions
diff --git a/test/files/neg/t0764.check b/test/files/neg/t0764.check
new file mode 100644
index 0000000000..0c7cff1e1e
--- /dev/null
+++ b/test/files/neg/t0764.check
@@ -0,0 +1,7 @@
+t0764.scala:13: error: type mismatch;
+ found : Node{type T = _1.type} where val _1: Node{type T = NextType}
+ required: Node{type T = Main.this.AType}
+ (which expands to) Node{type T = Node{type T = NextType}}
+ new Main[AType]( (value: AType).prepend )
+ ^
+one error found
diff --git a/test/files/neg/t0764.scala b/test/files/neg/t0764.scala
new file mode 100644
index 0000000000..9f77a59414
--- /dev/null
+++ b/test/files/neg/t0764.scala
@@ -0,0 +1,45 @@
+class Top[A] {
+ type AType = A
+}
+
+trait Node { outer =>
+ type T <: Node
+ def prepend = new Node { type T = outer.type }
+}
+
+class Main[NextType <: Node](value: Node { type T = NextType })
+ extends Top[Node { type T = NextType }] {
+
+ new Main[AType]( (value: AType).prepend )
+}
+
+/* we've been back-and-forth on this one -- see PRs on SI-8177 for the reasoning
+I think it should compile and that the following error is due to broken =:= on existentials
+ found : Node{type T = _1.type} where val _1: Node{type T = NextType}
+ required: Node{type T = Main.this.AType}
+ (which expands to) Node{type T = Node{type T = NextType}}
+
+I claim (omitting the forSome for brevity, even though the premature skolemization is probably the issue)
+_1.type =:= Main.this.AType
+because
+(1) _1.type <:< Main.this.AType and (2) Main.this.AType <:< _1.type
+(1), because:
+_1.type <:< Node{type T = NextType} (because skolemization and _1's upper bound)
+(2), because:
+Node{type T = NextType} <:< _1.type forSome val _1: Node{type T = NextType}
+because:
+Node{type T = NextType} <:< T forSome {type T <: Node{type T = NextType} with Singleton}
+because
+Node{type T = NextType} <:< Node{type T = NextType} with Singleton
+
+hmmm.. might the with Singleton be throwing a wrench in our existential house?
+
+Behold the equivalent program which type checks without the fix for SI-8177.
+(Expand type alias, convert type member to type param;
+note the covariance to encode subtyping on type members.)
+
+class Node[+T <: Node[_]] { def prepend = new Node[this.type] }
+class Main[NextType <: Node[_]](value: Node[NextType]) {
+ new Main(value.prepend)
+}
+*/ \ No newline at end of file
diff --git a/test/files/neg/t0764b.check b/test/files/neg/t0764b.check
new file mode 100644
index 0000000000..4040954e7c
--- /dev/null
+++ b/test/files/neg/t0764b.check
@@ -0,0 +1,47 @@
+t0764b.scala:27: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.NodeAlias[p1.t0764.NodeAlias[A]]
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f2 = new Main1[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:28: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.NodeAlias[p1.t0764.Node{type T = A}]
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f3 = new Main1[Node { type T = A }](v.prepend) // fail
+ ^
+t0764b.scala:34: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.Node{type T = p1.t0764.NodeAlias[A]}
+ (which expands to) p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f2 = new Main2[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:35: error: type mismatch;
+ found : p1.t0764.Node{type T = p1.t0764.<refinement>.type}
+ required: p1.t0764.Node{type T = p1.t0764.Node{type T = A}}
+ private[this] def f3 = new Main2[Node { type T = A }](v.prepend) // fail
+ ^
+t0764b.scala:51: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.NodeAlias[p2.t0764.NodeAlias[A]]
+ (which expands to) p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f2 = new Main1[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:52: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.NodeAlias[p2.t0764.Node{type T = A}]
+ (which expands to) p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f3 = new Main1[Node { type T = A }](v.prepend) // fail
+ ^
+t0764b.scala:58: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.Node{type T = p2.t0764.NodeAlias[A]}
+ (which expands to) p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f2 = new Main2[NodeAlias[A]](v.prepend) // fail
+ ^
+t0764b.scala:59: error: type mismatch;
+ found : p2.t0764.Node{type T = p2.t0764.<refinement>.type}
+ required: p2.t0764.Node{type T = p2.t0764.Node{type T = A}}
+ private[this] def f3 = new Main2[Node { type T = A }](v.prepend) // fail
+ ^
+8 errors found
diff --git a/test/files/pos/t0764b.scala b/test/files/neg/t0764b.scala
index 6ae3c105c9..14c623c67a 100644
--- a/test/files/pos/t0764b.scala
+++ b/test/files/neg/t0764b.scala
@@ -1,3 +1,5 @@
+// see neg/t0764 why this should probably be a pos/ test -- alas something's wrong with existential subtyping (?)
+
// In all cases when calling "prepend" the receiver 'v'
// has static type NodeAlias[A] or (equivalently) Node { type T = A }.
// Since prepend explicitly returns the singleton type of the receiver,
diff --git a/test/files/neg/t8104/Test_2.scala b/test/files/neg/t8104/Test_2.scala
index 585f76c00f..a3bd940188 100644
--- a/test/files/neg/t8104/Test_2.scala
+++ b/test/files/neg/t8104/Test_2.scala
@@ -9,7 +9,7 @@ object Test extends App {
case class C(x: Int, y: Int)
import scala.reflect.runtime.universe._
- def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag)
+ def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: WeakTypeTag[Repr]) = println(tag)
reprify(C(40, 2))
// this is a compilation error at the moment as explained in SI-8104
diff --git a/test/files/neg/t8177a.check b/test/files/neg/t8177a.check
new file mode 100644
index 0000000000..0d01206e0c
--- /dev/null
+++ b/test/files/neg/t8177a.check
@@ -0,0 +1,6 @@
+t8177a.scala:5: error: type mismatch;
+ found : A{type Result = Int}
+ required: A{type Result = String}
+ : A { type Result = String} = x
+ ^
+one error found
diff --git a/test/files/neg/t8177a.scala b/test/files/neg/t8177a.scala
new file mode 100644
index 0000000000..d1e47f8c1e
--- /dev/null
+++ b/test/files/neg/t8177a.scala
@@ -0,0 +1,6 @@
+trait A { type Result }
+
+class PolyTests {
+ def wrong(x: A { type Result = Int })
+ : A { type Result = String} = x
+} \ No newline at end of file
diff --git a/test/files/pos/t0764.scala b/test/files/pos/t0764.scala
deleted file mode 100644
index f1084f5ff8..0000000000
--- a/test/files/pos/t0764.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-class Top[A] {
- type AType = A
-}
-
-trait Node { outer =>
- type T <: Node
- def prepend = new Node { type T = outer.type }
-}
-
-class Main[NextType <: Node](value: Node { type T = NextType })
- extends Top[Node { type T = NextType }] {
-
- new Main[AType]( (value: AType).prepend )
-}
-
-/* this used to be a neg test, even though it should've compiled
-SI-8177 fixed this.
-
-Behold the equivalent program which type checks without the fix for SI-8177.
-(Expand type alias, convert type member to type param;
-note the covariance to encode subtyping on type members.)
-
-class Node[+T <: Node[_]] { def prepend = new Node[this.type] }
-class Main[NextType <: Node[_]](value: Node[NextType]) {
- new Main(value.prepend)
-}
-*/ \ No newline at end of file
diff --git a/test/files/pos/t1786-cycle.scala b/test/files/pos/t1786-cycle.scala
new file mode 100644
index 0000000000..af5d892c6a
--- /dev/null
+++ b/test/files/pos/t1786-cycle.scala
@@ -0,0 +1,57 @@
+trait GenTraversableLike[+A, +Repr] extends Any
+
+object O {
+ (null: Any) match {
+ case _: LongTraversableLike[_] =>
+ }
+}
+
+trait LongTraversable extends LongTraversableLike[LongTraversable]
+
+trait LongTraversableLike[+Repr <: LongTraversableLike[Repr]] extends GenTraversableLike[Any, Repr]
+
+/*
+% scalac-hash v2.11.0-M8 test/files/pos/t1786-cycle.scala
+[warn] v2.11.0-M8 failed, using closest available
+test/files/pos/t1786-cycle.scala:11: error: illegal cyclic reference involving trait LongTraversableLike
+trait LongTraversableLike[+Repr <: LongTraversableLike[Repr]] extends GenTraversableLike[Any, Repr]
+ ^
+one error found
+
+Okay again after SI-1786 was reverted.
+
+
+|-- object O BYVALmode-EXPRmode (site: package <empty>)
+| |-- super EXPRmode-POLYmode-QUALmode (silent: <init> in O)
+| | |-- this EXPRmode (silent: <init> in O)
+| | | \-> O.type
+| | \-> O.type
+| |-- (null: Any) match { case (_: LongTraversableLike[(_ @ <em... BYVALmode-EXPRmode (site: value <local O> in O)
+| | |-- (null: Any) BYVALmode-EXPRmode (site: value <local O> in O)
+| | | |-- Any TYPEmode (site: value <local O> in O)
+| | | | \-> Any
+| | | |-- null : pt=Any EXPRmode (site: value <local O> in O)
+| | | | \-> Null(null)
+| | | \-> Any
+| | |-- (_: LongTraversableLike[(_ @ <empty>)]) : pt=Any PATTERNmode (site: value <local O> in O) enrichment only
+| | | |-- LongTraversableLike[(_ @ <empty>)] TYPEPATmode-TYPEmode (site: value <local O> in O) enrichment only
+| | | | |-- <: LongTraversableLike[Repr] TYPEmode (site: type Repr in <empty>)
+| | | | | |-- LongTraversableLike[Repr] TYPEmode (site: type Repr in <empty>)
+| | | | | | |-- Repr NOmode (site: type Repr in <empty>)
+| | | | | | | \-> Repr
+| | | | | | \-> LongTraversableLike[Repr]
+| | | | | [adapt] <: LongTraversableLike[Repr] is now a TypeTree( <: LongTraversableLike[Repr])
+| | | | | \-> <: LongTraversableLike[Repr]
+| | | | |-- (_ @ <empty>) TYPEPATmode-TYPEmode (site: value <local O> in O) enrichment only
+| | | | | \-> _
+| | | | |-- GenTraversableLike FUNmode-TYPEmode (site: trait LongTraversableLike)
+| | | | | \-> GenTraversableLike
+| | | | |-- GenTraversableLike[Any, Repr] TYPEmode (site: trait LongTraversableLike)
+| | | | | |-- Any TYPEmode (site: trait LongTraversableLike)
+| | | | | | \-> Any
+| | | | | |-- Repr TYPEmode (site: trait LongTraversableLike)
+| | | | | | \-> Repr
+| | | | | caught scala.reflect.internal.Symbols$CyclicReference: illegal cyclic reference involving trait LongTraversableLike: while typing GenTraversableLike[Any, Repr]
+test/files/pos/t1786-cycle.scala:11: error: illegal cyclic reference involving trait LongTraversableLike
+trait LongTraversableLike[+Repr <: LongTraversableLike[Repr]] extends GenT
+*/ \ No newline at end of file
diff --git a/test/files/pos/t8177h.scala b/test/files/pos/t8177h.scala
new file mode 100644
index 0000000000..90b8a26ce7
--- /dev/null
+++ b/test/files/pos/t8177h.scala
@@ -0,0 +1,5 @@
+class Module { self =>
+ type settingsType <: Any
+ final type commonModuleType = Module {type settingsType = self.settingsType}
+ def foo(s: self.type): commonModuleType = s
+}
diff --git a/test/files/run/t6992.check b/test/files/run/t6992.check
index 1a0684c995..021f32ec95 100644
--- a/test/files/run/t6992.check
+++ b/test/files/run/t6992.check
@@ -1,3 +1,4 @@
+Test.foo.T
Int
42
42
diff --git a/test/files/run/t6992/Test_2.scala b/test/files/run/t6992/Test_2.scala
index 05282d6f5b..1ed8958d38 100644
--- a/test/files/run/t6992/Test_2.scala
+++ b/test/files/run/t6992/Test_2.scala
@@ -2,7 +2,9 @@ import scala.language.reflectiveCalls
object Test extends App {
val foo = Macros.foo("T")
- println(scala.reflect.runtime.universe.weakTypeOf[foo.T].typeSymbol.typeSignature)
+ val ttpe = scala.reflect.runtime.universe.weakTypeOf[foo.T]
+ println(ttpe)
+ println(ttpe.typeSymbol.typeSignature)
val bar = Macros.bar("test")
println(bar.test)
diff --git a/test/files/run/t8104.check b/test/files/run/t8104.check
index c2593eb199..40523a2868 100644
--- a/test/files/run/t8104.check
+++ b/test/files/run/t8104.check
@@ -1 +1,2 @@
-TypeTag[(Int, Int)]
+WeakTypeTag[<refinement>.this.Repr]
+(Int, Int)
diff --git a/test/files/run/t8104/Test_2.scala b/test/files/run/t8104/Test_2.scala
index 630176f175..55c080a563 100644
--- a/test/files/run/t8104/Test_2.scala
+++ b/test/files/run/t8104/Test_2.scala
@@ -9,7 +9,10 @@ object Test extends App {
case class C(x: Int, y: Int)
import scala.reflect.runtime.universe._
- def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: TypeTag[Repr]) = println(tag)
+ def reprify[T, Repr](x: T)(implicit generic: Generic.Aux[T, Repr], tag: WeakTypeTag[Repr]) = {
+ println(tag)
+ println(tag.tpe.typeSymbol.typeSignature)
+ }
reprify(C(40, 2))
implicitly[Generic.Aux[C, (Int, Int)]]
diff --git a/test/files/run/t8153.check b/test/files/run/t8153.check
new file mode 100644
index 0000000000..0cfbf08886
--- /dev/null
+++ b/test/files/run/t8153.check
@@ -0,0 +1 @@
+2
diff --git a/test/files/run/t8153.scala b/test/files/run/t8153.scala
new file mode 100644
index 0000000000..f9b223f974
--- /dev/null
+++ b/test/files/run/t8153.scala
@@ -0,0 +1,14 @@
+object Test {
+ def f() = {
+ val lb = scala.collection.mutable.ListBuffer[Int](1, 2)
+ val it = lb.iterator
+ if (it.hasNext) it.next
+ val xs = lb.toList
+ lb += 3
+ it.mkString
+ }
+
+ def main(args: Array[String]) {
+ println(f())
+ }
+}
diff --git a/test/files/run/t8280.check b/test/files/run/t8280.check
new file mode 100644
index 0000000000..ed392841c7
--- /dev/null
+++ b/test/files/run/t8280.check
@@ -0,0 +1,9 @@
+Int
+Int
+Int
+Int
+Int
+Int
+Int
+Int
+Int
diff --git a/test/files/run/t8280.scala b/test/files/run/t8280.scala
new file mode 100644
index 0000000000..0734d63b6e
--- /dev/null
+++ b/test/files/run/t8280.scala
@@ -0,0 +1,82 @@
+import scala.language.implicitConversions
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ Moop1.ob1
+ Moop1.ob2
+ Moop1.ob3
+ Moop2.ob1
+ Moop2.ob2
+ Moop2.ob3
+ Moop3.ob1
+ Moop3.ob2
+ Moop3.ob3
+ }
+}
+
+// int object vs.
+object Moop1 {
+ object ob1 {
+ implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
+ implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" }
+
+ println(5: String)
+ }
+ object ob2 {
+ implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
+ implicit def f2(x: Long): String = "Long"
+
+ println(5: String)
+ }
+ object ob3 {
+ implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
+ implicit val f2: Long => String = _ => "Long"
+
+ println(5: String)
+ }
+}
+
+// int def vs.
+object Moop2 {
+ object ob1 {
+ implicit def f1(x: Int): String = "Int"
+ implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" }
+
+ println(5: String)
+ }
+ object ob2 {
+ implicit def f1(x: Int): String = "Int"
+ implicit def f2(x: Long): String = "Long"
+
+ println(5: String)
+ }
+ object ob3 {
+ implicit def f1(x: Int): String = "Int"
+ implicit val f2: Long => String = _ => "Long"
+
+ println(5: String)
+ }
+}
+
+// int val vs.
+object Moop3 {
+ object ob1 {
+ implicit val f1: Int => String = _ => "Int"
+ implicit object f2 extends (Long => String) { def apply(x: Long): String = "Long" }
+
+ println(5: String)
+ }
+ object ob2 {
+ implicit val f1: Int => String = _ => "Int"
+ implicit def f2(x: Long): String = "Long"
+
+ println(5: String)
+ }
+ object ob3 {
+ implicit val f1: Int => String = _ => "Int"
+ implicit val f2: Long => String = _ => "Long"
+
+ println(5: String)
+ }
+}
+