summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/run/t7044.check14
-rw-r--r--test/files/run/t7044/Macros_1.scala26
-rw-r--r--test/files/run/t7044/Test_2.scala19
3 files changed, 59 insertions, 0 deletions
diff --git a/test/files/run/t7044.check b/test/files/run/t7044.check
new file mode 100644
index 0000000000..ab523873bf
--- /dev/null
+++ b/test/files/run/t7044.check
@@ -0,0 +1,14 @@
+compile-time
+uninitialized File: <no file>
+initialized File: <no file>
+uninitialized BitSet: <no file>
+initialized BitSet: <no file>
+uninitialized C: Test_2.scala
+initialized C: Test_2.scala
+runtime
+autoinitialized File: <no file> true
+autoinitialized File: <no file> true
+autoinitialized BitSet: <no file> true
+autoinitialized BitSet: <no file> true
+autoinitialized C: <no file> true
+autoinitialized C: <no file> true
diff --git a/test/files/run/t7044/Macros_1.scala b/test/files/run/t7044/Macros_1.scala
new file mode 100644
index 0000000000..3b3f8c3385
--- /dev/null
+++ b/test/files/run/t7044/Macros_1.scala
@@ -0,0 +1,26 @@
+import scala.reflect.macros.whitebox._
+import scala.language.experimental.macros
+
+object Macros {
+ def impl(c: Context) = {
+ var messages = List[String]()
+ def println(msg: String) = messages :+= msg
+
+ import c.universe._
+ def test(tpe: Type): Unit = {
+ val sym = tpe.typeSymbol
+ println(s"uninitialized ${sym.name}: ${sym.pos.source.file.name}")
+ internal.initialize(sym)
+ println(s"initialized ${sym.name}: ${sym.pos.source.file.name}")
+ }
+
+ println("compile-time")
+ test(typeOf[java.io.File])
+ test(typeOf[scala.collection.BitSet])
+ test(c.mirror.staticClass("C").toType)
+
+ q"..${messages.map(msg => q"println($msg)")}"
+ }
+
+ def foo: Any = macro impl
+} \ No newline at end of file
diff --git a/test/files/run/t7044/Test_2.scala b/test/files/run/t7044/Test_2.scala
new file mode 100644
index 0000000000..8dfb349086
--- /dev/null
+++ b/test/files/run/t7044/Test_2.scala
@@ -0,0 +1,19 @@
+import scala.reflect.runtime.universe._
+import scala.reflect.runtime.{currentMirror => cm}
+
+class C
+
+object Test extends App {
+ def test(tpe: Type): Unit = {
+ val sym = tpe.typeSymbol
+ println(s"autoinitialized ${sym.name}: ${sym.pos.source.file.name} ${sym.pos.source.file.sizeOption.nonEmpty}")
+ internal.initialize(sym)
+ println(s"autoinitialized ${sym.name}: ${sym.pos.source.file.name} ${sym.pos.source.file.sizeOption.nonEmpty}")
+ }
+
+ Macros.foo
+ println("runtime")
+ test(typeOf[java.io.File])
+ test(typeOf[scala.collection.BitSet])
+ test(typeOf[C])
+}