summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/files/neg/t7046-2.check3
-rw-r--r--test/files/neg/t7046-2/Macros_1.scala15
-rw-r--r--test/files/neg/t7046-2/Test_2.scala14
-rw-r--r--test/files/neg/t7046.check3
-rw-r--r--test/files/neg/t7046/Macros_1.scala15
-rw-r--r--test/files/neg/t7046/Test_2.scala35
-rw-r--r--test/files/pos/t7046-2/Macros_1.scala14
-rw-r--r--test/files/pos/t7046-2/Test_2.scala9
-rw-r--r--test/files/run/t7046-1/Macros_1.scala15
-rw-r--r--test/files/run/t7046-1/Test_2.scala23
-rw-r--r--test/files/run/t7046-2/Macros_1.scala15
-rw-r--r--test/files/run/t7046-2/Test_2.scala14
-rw-r--r--test/files/run/virtpatmat_staging.flags2
-rw-r--r--test/pending/neg/t5729.check7
-rw-r--r--test/pending/neg/t5729.scala (renamed from test/files/pos/t5729.scala)0
15 files changed, 183 insertions, 1 deletions
diff --git a/test/files/neg/t7046-2.check b/test/files/neg/t7046-2.check
new file mode 100644
index 0000000000..b4efd8b5e9
--- /dev/null
+++ b/test/files/neg/t7046-2.check
@@ -0,0 +1,3 @@
+error: knownDirectSubclasses of Foo observed before subclass Bar registered
+error: knownDirectSubclasses of Foo observed before subclass Baz registered
+two errors found
diff --git a/test/files/neg/t7046-2/Macros_1.scala b/test/files/neg/t7046-2/Macros_1.scala
new file mode 100644
index 0000000000..2a5bf82f62
--- /dev/null
+++ b/test/files/neg/t7046-2/Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl[T](c: Context)(implicit ttag: c.WeakTypeTag[T]): c.Expr[List[String]] = {
+ import c.universe._;
+ val ttpe = ttag.tpe
+ val tsym = ttpe.typeSymbol.asClass
+ val subclasses = tsym.knownDirectSubclasses.toList.map(_.name.toString)
+
+ c.Expr[List[String]](q"$subclasses")
+ }
+
+ def knownDirectSubclasses[T]: List[String] = macro impl[T]
+}
diff --git a/test/files/neg/t7046-2/Test_2.scala b/test/files/neg/t7046-2/Test_2.scala
new file mode 100644
index 0000000000..18a2ebcbc2
--- /dev/null
+++ b/test/files/neg/t7046-2/Test_2.scala
@@ -0,0 +1,14 @@
+object Test extends App {
+ def nested: Unit = {
+ val subs = Macros.knownDirectSubclasses[Foo]
+ assert(subs == List("Bar", "Baz"))
+
+ sealed trait Foo
+ object Foo {
+ trait Bar extends Foo
+ trait Baz extends Foo
+ }
+ }
+
+ nested
+}
diff --git a/test/files/neg/t7046.check b/test/files/neg/t7046.check
new file mode 100644
index 0000000000..689520a0aa
--- /dev/null
+++ b/test/files/neg/t7046.check
@@ -0,0 +1,3 @@
+error: knownDirectSubclasses of Foo observed before subclass Local registered
+error: knownDirectSubclasses of Foo observed before subclass Riddle registered
+two errors found
diff --git a/test/files/neg/t7046/Macros_1.scala b/test/files/neg/t7046/Macros_1.scala
new file mode 100644
index 0000000000..2a5bf82f62
--- /dev/null
+++ b/test/files/neg/t7046/Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl[T](c: Context)(implicit ttag: c.WeakTypeTag[T]): c.Expr[List[String]] = {
+ import c.universe._;
+ val ttpe = ttag.tpe
+ val tsym = ttpe.typeSymbol.asClass
+ val subclasses = tsym.knownDirectSubclasses.toList.map(_.name.toString)
+
+ c.Expr[List[String]](q"$subclasses")
+ }
+
+ def knownDirectSubclasses[T]: List[String] = macro impl[T]
+}
diff --git a/test/files/neg/t7046/Test_2.scala b/test/files/neg/t7046/Test_2.scala
new file mode 100644
index 0000000000..fcb3e46a0f
--- /dev/null
+++ b/test/files/neg/t7046/Test_2.scala
@@ -0,0 +1,35 @@
+object Test extends App {
+ val subs = Macros.knownDirectSubclasses[Foo]
+ assert(subs == List("Wibble", "Wobble", "Bar", "Baz"))
+}
+
+sealed trait Foo
+object Foo {
+ trait Wibble extends Foo
+ case object Wobble extends Foo
+}
+
+trait Bar extends Foo
+
+object Blah {
+ type Quux = Foo
+}
+
+import Blah._
+
+trait Baz extends Quux
+
+class Boz[T](t: T)
+class Unrelated extends Boz(Test.subs)
+
+object Enigma {
+ locally {
+ // local class not seen
+ class Local extends Foo
+ }
+
+ def foo: Unit = {
+ // local class not seen
+ class Riddle extends Foo
+ }
+}
diff --git a/test/files/pos/t7046-2/Macros_1.scala b/test/files/pos/t7046-2/Macros_1.scala
new file mode 100644
index 0000000000..07c0c61281
--- /dev/null
+++ b/test/files/pos/t7046-2/Macros_1.scala
@@ -0,0 +1,14 @@
+package p1
+
+import scala.reflect.macros.blackbox._
+import language.experimental._
+
+object Macro {
+ def impl(c: Context): c.Tree = {
+ import c.universe._
+ val tsym = rootMirror.staticClass("p1.Base")
+ val subclasses = tsym.knownDirectSubclasses.toList.map(_.name.toString)
+ q"$subclasses"
+ }
+ def p1_Base_knownDirectSubclasses: List[String] = macro impl
+}
diff --git a/test/files/pos/t7046-2/Test_2.scala b/test/files/pos/t7046-2/Test_2.scala
new file mode 100644
index 0000000000..74e30a863d
--- /dev/null
+++ b/test/files/pos/t7046-2/Test_2.scala
@@ -0,0 +1,9 @@
+package p1
+
+sealed trait Base
+
+object Test {
+ val x = Macro.p1_Base_knownDirectSubclasses
+}
+
+case class B(val b: Test.x.type)
diff --git a/test/files/run/t7046-1/Macros_1.scala b/test/files/run/t7046-1/Macros_1.scala
new file mode 100644
index 0000000000..2a5bf82f62
--- /dev/null
+++ b/test/files/run/t7046-1/Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl[T](c: Context)(implicit ttag: c.WeakTypeTag[T]): c.Expr[List[String]] = {
+ import c.universe._;
+ val ttpe = ttag.tpe
+ val tsym = ttpe.typeSymbol.asClass
+ val subclasses = tsym.knownDirectSubclasses.toList.map(_.name.toString)
+
+ c.Expr[List[String]](q"$subclasses")
+ }
+
+ def knownDirectSubclasses[T]: List[String] = macro impl[T]
+}
diff --git a/test/files/run/t7046-1/Test_2.scala b/test/files/run/t7046-1/Test_2.scala
new file mode 100644
index 0000000000..28459fde72
--- /dev/null
+++ b/test/files/run/t7046-1/Test_2.scala
@@ -0,0 +1,23 @@
+object Test extends App {
+ val subs = Macros.knownDirectSubclasses[Foo]
+ assert(subs == List("Wibble", "Wobble", "Bar", "Baz"))
+}
+
+sealed trait Foo
+object Foo {
+ trait Wibble extends Foo
+ case object Wobble extends Foo
+}
+
+trait Bar extends Foo
+
+object Blah {
+ type Quux = Foo
+}
+
+import Blah._
+
+trait Baz extends Quux
+
+class Boz[T](t: T)
+class Unrelated extends Boz(Test.subs)
diff --git a/test/files/run/t7046-2/Macros_1.scala b/test/files/run/t7046-2/Macros_1.scala
new file mode 100644
index 0000000000..2a5bf82f62
--- /dev/null
+++ b/test/files/run/t7046-2/Macros_1.scala
@@ -0,0 +1,15 @@
+import scala.language.experimental.macros
+import scala.reflect.macros.blackbox.Context
+
+object Macros {
+ def impl[T](c: Context)(implicit ttag: c.WeakTypeTag[T]): c.Expr[List[String]] = {
+ import c.universe._;
+ val ttpe = ttag.tpe
+ val tsym = ttpe.typeSymbol.asClass
+ val subclasses = tsym.knownDirectSubclasses.toList.map(_.name.toString)
+
+ c.Expr[List[String]](q"$subclasses")
+ }
+
+ def knownDirectSubclasses[T]: List[String] = macro impl[T]
+}
diff --git a/test/files/run/t7046-2/Test_2.scala b/test/files/run/t7046-2/Test_2.scala
new file mode 100644
index 0000000000..79407f522f
--- /dev/null
+++ b/test/files/run/t7046-2/Test_2.scala
@@ -0,0 +1,14 @@
+object Test extends App {
+ def nested: Unit = {
+ sealed trait Foo
+ object Foo {
+ trait Bar extends Foo
+ trait Baz extends Foo
+ }
+
+ val subs = Macros.knownDirectSubclasses[Foo]
+ assert(subs == List("Bar", "Baz"))
+ }
+
+ nested
+}
diff --git a/test/files/run/virtpatmat_staging.flags b/test/files/run/virtpatmat_staging.flags
index 0a22f7c729..bec3aa96e9 100644
--- a/test/files/run/virtpatmat_staging.flags
+++ b/test/files/run/virtpatmat_staging.flags
@@ -1,2 +1,2 @@
-Yrangepos:false
--Xexperimental
+-Yvirtpatmat
diff --git a/test/pending/neg/t5729.check b/test/pending/neg/t5729.check
new file mode 100644
index 0000000000..10c13db8b6
--- /dev/null
+++ b/test/pending/neg/t5729.check
@@ -0,0 +1,7 @@
+t5729.scala:5: error: ambiguous reference to overloaded definition,
+both method join in object Test of type [S](in: Seq[T[S]])String
+and method join in object Test of type (in: Seq[T[_]])Int
+match argument types (Seq[T[_]])
+ join(null: Seq[T[_]])
+ ^
+one error found
diff --git a/test/files/pos/t5729.scala b/test/pending/neg/t5729.scala
index 9fd9c9ffbb..9fd9c9ffbb 100644
--- a/test/files/pos/t5729.scala
+++ b/test/pending/neg/t5729.scala