Skip to content

Commit 1eca461

Browse files
committed
Fix scala#3533: Fix parsing of raw types appearing in generic position
Only the ClassfileParser is fixed (because we can just ask users to fix their Java source files to not use raw types to get them to compile with Dotty). This means that the added Java testcase does not pass Dotty's Java source parser, we handle this by putting "JAVA_ONLY" in the filename and skipping files that contain this string from going through Dotty in our testing framework.
1 parent 7d1fd0d commit 1eca461

File tree

5 files changed

+16
-4
lines changed

5 files changed

+16
-4
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,11 @@ class ClassfileParser(
261261
addConstructorTypeParams(denot)
262262
}
263263

264-
denot.info = cook.apply(pool.getType(in.nextChar))
264+
denot.info = pool.getType(in.nextChar)
265265
if (isEnum) denot.info = ConstantType(Constant(sym))
266266
if (isConstructor) normalizeConstructorParams()
267267
setPrivateWithin(denot, jflags)
268-
denot.info = translateTempPoly(parseAttributes(sym, denot.info))
268+
denot.info = translateTempPoly(cook.apply(parseAttributes(sym, denot.info)))
269269
if (isConstructor) normalizeConstructorInfo()
270270

271271
if ((denot is Flags.Method) && (jflags & JAVA_ACC_VARARGS) != 0)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class CompilationTests extends ParallelTesting {
6969
),
7070
scala2Mode
7171
) +
72+
compileFilesInDir("../tests/pos-special/i3273", defaultOptions) +
7273
compileFilesInDir("../tests/pos-special/spec-t5545", defaultOptions) +
7374
compileFilesInDir("../tests/pos-special/strawman-collections", defaultOptions) +
7475
compileFile("../scala2-library/src/library/scala/collection/immutable/IndexedSeq.scala", defaultOptions) +
@@ -109,7 +110,6 @@ class CompilationTests extends ParallelTesting {
109110
implicit val testGroup: TestGroup = TestGroup("posTwice")
110111
compileFile("../tests/pos/Labels.scala", defaultOptions) +
111112
compileFilesInDir("../tests/pos-java-interop", defaultOptions) +
112-
compileFilesInDir("../tests/pos-java-interop-separate", defaultOptions) +
113113
compileFile("../tests/pos/t2168.scala", defaultOptions) +
114114
compileFile("../tests/pos/erasure.scala", defaultOptions) +
115115
compileFile("../tests/pos/Coder.scala", defaultOptions) +

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
376376

377377
// Compile with a try to catch any StackTrace generated by the compiler:
378378
try {
379-
driver.process(allArgs ++ files.map(_.getAbsolutePath), reporter = reporter)
379+
// If a test contains a Java file that cannot be parsed by Dotty's Java source parser, its
380+
// name must contain the string "JAVA_ONLY".
381+
val dottyFiles = files.filterNot(_.getName.contains("JAVA_ONLY")).map(_.getAbsolutePath)
382+
driver.process(allArgs ++ dottyFiles, reporter = reporter)
380383

381384
val javaFiles = files.filter(_.getName.endsWith(".java")).map(_.getAbsolutePath)
382385
val javaErrors = compileWithJavac(javaFiles)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
TryMe_JAVA_ONLY_1.ifYouCan(list => list.size())
3+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import java.util.function.Function;
2+
3+
public class TryMe_JAVA_ONLY_1 {
4+
public static void ifYouCan(Function<java.util.List, Integer> f) {
5+
}
6+
}

0 commit comments

Comments
 (0)