Skip to content

Commit d19a792

Browse files
committed
Fix #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 d19a792

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class ClassfileParser(
161161

162162
for (i <- 0 until in.nextChar) parseMember(method = false)
163163
for (i <- 0 until in.nextChar) parseMember(method = true)
164-
classInfo = cook.apply(parseAttributes(classRoot.symbol, classInfo))
164+
classInfo = parseAttributes(classRoot.symbol, classInfo)
165165
if (isAnnotation) addAnnotationConstructor(classInfo)
166166

167167
val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, classRoot, moduleRoot)
@@ -261,7 +261,7 @@ 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)
@@ -625,7 +625,8 @@ class ClassfileParser(
625625
for (i <- 0 until in.nextChar) {
626626
parseAttribute()
627627
}
628-
newType
628+
629+
cook.apply(newType)
629630
}
630631

631632
/** Add synthetic constructor(s) and potentially also default getters which

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)