-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Compiler arguments written to: argfile-run.obj/print-args.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
import java.nio.file.Files | ||
|
||
import scala.jdk.CollectionConverters._ | ||
import scala.reflect.internal.util._ | ||
import scala.tools.nsc.{CompilerCommand, Settings} | ||
import scala.tools.partest.DirectTest | ||
import scala.util.chaining._ | ||
|
||
object Test extends DirectTest { | ||
var count = 0 | ||
lazy val argfile = testOutput.jfile.toPath().resolve("print-args.txt") | ||
lazy val goodarg = testOutput.jfile.toPath().resolve("print-args2.txt") | ||
override def extraSettings = | ||
if (count == 0) s"""${super.extraSettings} -Xsource:3 -Vprint-args $argfile "-Wconf:cat=unused-nowarn&msg=does not suppress&site=C:s"""" | ||
else s"@$goodarg" | ||
|
||
// Use CompilerCommand for expanding the args file. | ||
override def newSettings(args: List[String]) = (new Settings).tap { s => | ||
val cc = new CompilerCommand(args, s) | ||
assert(cc.ok) | ||
assert(cc.files.isEmpty) | ||
} | ||
def code = | ||
sm""" | ||
|@annotation.nowarn | ||
|final class C { | ||
| def f: Int = "42".toInt | ||
|} | ||
""" | ||
def show() = { | ||
assert(compile()) | ||
// drop "-Vprint-args .../print-args.txt newSource1.scala" | ||
val args = Files.readAllLines(argfile).asScala.toList.dropRight(3) | ||
Files.write(goodarg, args.asJava) | ||
count += 1 | ||
assert(compile()) | ||
} | ||
} |