Skip to content

Commit 1a52057

Browse files
authored
Merge pull request #3755 from dotty-staging/fix-raw-in-generic
Fix #3533: Fix parsing of raw types appearing in generic position
2 parents 7e402a7 + d19a792 commit 1a52057

File tree

7 files changed

+18
-5
lines changed

7 files changed

+18
-5
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/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ class CompilationTests extends ParallelTesting {
6969
),
7070
scala2Mode
7171
) +
72-
compileFilesInDir("../tests/pos-special/i3273", defaultOptions) +
7372
compileFilesInDir("../tests/pos-special/spec-t5545", defaultOptions) +
7473
compileFilesInDir("../tests/pos-special/strawman-collections", defaultOptions) +
7574
compileFile("../scala2-library/src/library/scala/collection/immutable/IndexedSeq.scala", defaultOptions) +
@@ -110,6 +109,7 @@ class CompilationTests extends ParallelTesting {
110109
implicit val testGroup: TestGroup = TestGroup("posTwice")
111110
compileFile("../tests/pos/Labels.scala", defaultOptions) +
112111
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)