Skip to content

Commit e63752b

Browse files
committed
Add test for named parameters from compiled classfile
1 parent 0902c3b commit e63752b

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class CompilationTests {
4242
compileFilesInDir("tests/pos-custom-args/erased", defaultOptions.and("-Yerased-terms")),
4343
compileFilesInDir("tests/pos", defaultOptions),
4444
compileFilesInDir("tests/pos-deep-subtype", allowDeepSubtypes),
45+
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
4546
compileFile(
4647
// succeeds despite -Xfatal-warnings because of -nowarn
4748
"tests/neg-custom-args/fatal-warnings/xfatalWarnings.scala",

compiler/test/dotty/tools/vulpix/TestFlags.scala

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@ import java.io.{File => JFile}
55
final case class TestFlags(
66
defaultClassPath: String,
77
runClassPath: String, // class path that is used when running `run` tests (not compiling)
8-
options: Array[String]) {
8+
options: Array[String],
9+
javacOptions: Array[String]) {
910

1011
def and(flags: String*): TestFlags =
11-
TestFlags(defaultClassPath, runClassPath, options ++ flags)
12+
TestFlags(defaultClassPath, runClassPath, options ++ flags, javacOptions)
1213

1314
def without(flags: String*): TestFlags =
14-
TestFlags(defaultClassPath, runClassPath, options diff flags)
15+
TestFlags(defaultClassPath, runClassPath, options diff flags, javacOptions)
1516

1617
def withClasspath(classPath: String): TestFlags =
17-
TestFlags(s"$defaultClassPath${JFile.pathSeparator}$classPath", runClassPath, options)
18+
TestFlags(s"$defaultClassPath${JFile.pathSeparator}$classPath", runClassPath, options, javacOptions)
1819

1920
def withRunClasspath(classPath: String): TestFlags =
20-
TestFlags(defaultClassPath, s"$runClassPath${JFile.pathSeparator}$classPath", options)
21+
TestFlags(defaultClassPath, s"$runClassPath${JFile.pathSeparator}$classPath", options, javacOptions)
22+
23+
def withJavacOnlyOptions(flags: String*): TestFlags =
24+
TestFlags(defaultClassPath, runClassPath, options, javacOptions ++ flags)
2125

2226
def all: Array[String] = Array("-classpath", defaultClassPath) ++ options
2327

@@ -43,10 +47,10 @@ final case class TestFlags(
4347
val flags = all
4448
val cp = flags.dropWhile(_ != "-classpath").take(2)
4549
val output = flags.dropWhile(_ != "-d").take(2)
46-
cp ++ output
50+
cp ++ output ++ javacOptions
4751
}
4852
}
4953

5054
object TestFlags {
51-
def apply(classPath: String, flags: Array[String]): TestFlags = TestFlags(classPath, classPath, flags)
55+
def apply(classPath: String, flags: Array[String]): TestFlags = TestFlags(classPath, classPath, flags, Array.empty)
5256
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
public class Foo_1 {
2+
public Foo_1(int number, String text) {}
3+
public void bar(String barText, int barNumber) {}
4+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@main def Test =
2+
new Foo_1(number = 6, text = "param-name").bar(barNumber = 8, barText = "some-method")

0 commit comments

Comments
 (0)