diff --git a/src/partest/scala/tools/partest/nest/Runner.scala b/src/partest/scala/tools/partest/nest/Runner.scala index 990ed6be347a..d5c63ed442ea 100644 --- a/src/partest/scala/tools/partest/nest/Runner.scala +++ b/src/partest/scala/tools/partest/nest/Runner.scala @@ -453,10 +453,12 @@ class Runner(val testInfo: TestInfo, val suiteRunner: AbstractRunner) { } // all sources in a round may contribute flags via // scalac: -flags + // if a javaVersion isn't specified, require the minimum viable using -release 8 to avoid gotcha in CI. def flagsForCompilation(sources: List[File]): List[String] = { - val perFile = toolArgsFor(sources)("scalac") - if (parentFile.getParentFile.getName == "macro-annot") "-Ymacro-annotations" :: perFile - else perFile + var perFile = toolArgsFor(sources)("scalac") + if (parentFile.getParentFile.getName == "macro-annot") perFile ::= "-Ymacro-annotations" + if (toolArgsFor(sources)("javaVersion", split = false).isEmpty) perFile :::= List("-release", "8") + perFile } // inspect sources for tool args diff --git a/test/files/neg/nonunit-statement.scala b/test/files/neg/nonunit-statement.scala index 9fa91069305f..1b53fc12b4c0 100644 --- a/test/files/neg/nonunit-statement.scala +++ b/test/files/neg/nonunit-statement.scala @@ -156,6 +156,7 @@ class J { import java.util.Collections def xs: java.util.List[Int] = ??? def f(): Int = { + java.util.List.of[Int]() Collections.checkedList[Int](xs, classOf[Int]) 42 }