summaryrefslogtreecommitdiff
path: root/test/files/pos/t5183.scala
diff options
context:
space:
mode:
Diffstat (limited to 'test/files/pos/t5183.scala')
-rw-r--r--test/files/pos/t5183.scala34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/files/pos/t5183.scala b/test/files/pos/t5183.scala
new file mode 100644
index 0000000000..783b8c28dc
--- /dev/null
+++ b/test/files/pos/t5183.scala
@@ -0,0 +1,34 @@
+trait Day
+
+object Test {
+ def foo(t: Int with Day) = t == t
+}
+
+class DayOps(val i: Int with Day) extends AnyVal
+
+case class Test1(d: Int with Day)
+case class Test2(d1: Int with Day, d2: Int with Day)
+
+class User
+class Checkin
+object Example {
+
+ type Tagged[U] = { type Tag = U }
+ type @@[T, U] = T with Tagged[U] // Thanks to @retronym for suggesting this type alias
+
+ class Tagger[U] {
+ def apply[T](t : T) : T @@ U = t.asInstanceOf[T @@ U]
+ }
+ def tag[U] = new Tagger[U]
+
+ // Manual specialization needed here ... specializing apply above doesn't help
+ def tag[U](i : Int) : Int @@ U = i.asInstanceOf[Int @@ U]
+ def tag[U](l : Long) : Long @@ U = l.asInstanceOf[Long @@ U]
+ def tag[U](d : Double) : Double @@ U = d.asInstanceOf[Double @@ U]
+
+ def fetch[A](id: Int @@ A): A = null.asInstanceOf[A]
+
+ def tag[U](arr: Array[Int]):Array[Int @@ U] = arr.asInstanceOf[Array[Int @@ U]]
+
+ tag[User](Array(3, 4, 5)).map(_.toString)
+} \ No newline at end of file