aboutsummaryrefslogtreecommitdiff
path: root/tests/run/t8346.scala
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run/t8346.scala')
-rw-r--r--tests/run/t8346.scala34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/run/t8346.scala b/tests/run/t8346.scala
new file mode 100644
index 000000000..1c34ab35f
--- /dev/null
+++ b/tests/run/t8346.scala
@@ -0,0 +1,34 @@
+object Test extends dotty.runtime.LegacyApp {
+ import reflect.ClassTag
+
+ object SomeEnum extends Enumeration {
+ val one, two, three, four = Value
+ }
+
+ def sctor[A <: Set[Int]](f: Int => A)(implicit A: ClassTag[A])
+ : (String, Int => Set[Int]) =
+ (A.runtimeClass.getSimpleName, f)
+
+ val inits: Seq[(String, Int => Set[Int])] = {
+ import collection.immutable.{Seq => _, _}
+ Seq(sctor(BitSet(_)),
+ sctor(HashSet(_)),
+ sctor(ListSet(_)),
+ sctor(SortedSet(_)),
+ sctor(TreeSet(_)))
+ }
+
+ def sVarInfo[A](sa: Set[A]): String = {
+ val saa = sa.toSet[Any]
+ if (sa eq saa) s"""covariant (${(saa + "hi") contains "hi"})"""
+ else "invariant"
+ }
+
+ inits foreach {case (name, singleton) =>
+ print(s"${name}: ")
+ val one = singleton(1)
+ println(Seq(2,3,4).scanLeft(one)(_ + _) map sVarInfo toList)
+ }
+
+ println(s"ValueSet: ${sVarInfo(SomeEnum.values)}")
+}