summaryrefslogtreecommitdiff
path: root/test/files
diff options
context:
space:
mode:
Diffstat (limited to 'test/files')
-rw-r--r--test/files/presentation/t8085.check3
-rw-r--r--test/files/presentation/t8085.flags1
-rw-r--r--test/files/presentation/t8085/Test.scala28
-rw-r--r--test/files/presentation/t8085/src/nodescala/Foo.scala3
-rw-r--r--test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala12
-rw-r--r--test/files/presentation/t8085/src/nodescala/package.scala8
6 files changed, 55 insertions, 0 deletions
diff --git a/test/files/presentation/t8085.check b/test/files/presentation/t8085.check
new file mode 100644
index 0000000000..46aac791f5
--- /dev/null
+++ b/test/files/presentation/t8085.check
@@ -0,0 +1,3 @@
+reload: NodeScalaSuite.scala
+prefixes differ: <empty>.nodescala,nodescala
+value always is not a member of object scala.concurrent.Future
diff --git a/test/files/presentation/t8085.flags b/test/files/presentation/t8085.flags
new file mode 100644
index 0000000000..ec35b223d8
--- /dev/null
+++ b/test/files/presentation/t8085.flags
@@ -0,0 +1 @@
+-sourcepath src
diff --git a/test/files/presentation/t8085/Test.scala b/test/files/presentation/t8085/Test.scala
new file mode 100644
index 0000000000..5d11009818
--- /dev/null
+++ b/test/files/presentation/t8085/Test.scala
@@ -0,0 +1,28 @@
+import scala.tools.nsc.interactive.tests.InteractiveTest
+import scala.reflect.internal.util.SourceFile
+import scala.tools.nsc.interactive.Response
+
+object Test extends InteractiveTest {
+
+ override def execute(): Unit = {
+ // loadSourceAndWaitUntilTypechecked("package.scala") // <-- uncomment this line and the test succeed
+ val src = loadSourceAndWaitUntilTypechecked("NodeScalaSuite.scala")
+ checkErrors(src)
+ }
+
+ private def loadSourceAndWaitUntilTypechecked(sourceName: String): SourceFile = {
+ val sourceFile = sourceFiles.find(_.file.name == sourceName).head
+ askReload(List(sourceFile)).get
+ askLoadedTyped(sourceFile).get
+ sourceFile
+ }
+
+ private def checkErrors(source: SourceFile): Unit = compiler.getUnitOf(source) match {
+ case Some(unit) =>
+ val problems = unit.problems.toList
+ if(problems.isEmpty) reporter.println("Test OK")
+ else problems.foreach(problem => reporter.println(problem.msg))
+
+ case None => reporter.println("No compilation unit found for " + source.file.name)
+ }
+}
diff --git a/test/files/presentation/t8085/src/nodescala/Foo.scala b/test/files/presentation/t8085/src/nodescala/Foo.scala
new file mode 100644
index 0000000000..19efdb65dd
--- /dev/null
+++ b/test/files/presentation/t8085/src/nodescala/Foo.scala
@@ -0,0 +1,3 @@
+package nodescala
+
+class Foo
diff --git a/test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala b/test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala
new file mode 100644
index 0000000000..a8803ff86d
--- /dev/null
+++ b/test/files/presentation/t8085/src/nodescala/NodeScalaSuite.scala
@@ -0,0 +1,12 @@
+package nodescala
+
+import scala.concurrent.Future
+
+class NodeScalaSuite {
+ Future.always(517)
+
+ // This is here only to prove that the presentation compiler is instantiated with the
+ // correct `sourcepath` value (if it wasn't, you would see a `not found: type Foo` in
+ // the test's output
+ println(new Foo())
+} \ No newline at end of file
diff --git a/test/files/presentation/t8085/src/nodescala/package.scala b/test/files/presentation/t8085/src/nodescala/package.scala
new file mode 100644
index 0000000000..6e9d4b729a
--- /dev/null
+++ b/test/files/presentation/t8085/src/nodescala/package.scala
@@ -0,0 +1,8 @@
+import scala.concurrent.Future // <-- if you move the import *inside* the package object, then it all works fine!!
+
+package object nodescala {
+ implicit class FutureCompanionOps[T](val f: Future.type) extends AnyVal {
+ def always[T](value: T): Future[T] = Promise[T].success(value).future
+ }
+}
+