From 7d1fd0dee0a04b7395aadc3906e24e0043b3805f Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 4 Jan 2018 22:21:54 +0100 Subject: [PATCH 1/2] Add folder for Java interop tests that do not support join compilation Quoting from d8ff147801a0a088b2c476918271f97e1a809586: Legacy-tests seems to always compile files together, but cooking only works for Java files read by ClassfileParser. I don't think it makes sense to change that - if we compile Java files from sources we should demand that raw types are re-written as wildcard types. Since other tests in the same situation will be added in the future, we create a `pos-java-interop-separate` test folder to keep them together. --- compiler/test/dotty/tools/dotc/CompilationTests.scala | 2 +- .../i3273/test => pos-java-interop-separate/i3273}/Bar_1.java | 0 .../test => pos-java-interop-separate/i3273}/client_2.scala | 0 3 files changed, 1 insertion(+), 1 deletion(-) rename tests/{pos-special/i3273/test => pos-java-interop-separate/i3273}/Bar_1.java (100%) rename tests/{pos-special/i3273/test => pos-java-interop-separate/i3273}/client_2.scala (100%) diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index e79121c7fe6e..f382d89f3946 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -69,7 +69,6 @@ class CompilationTests extends ParallelTesting { ), scala2Mode ) + - compileFilesInDir("../tests/pos-special/i3273", defaultOptions) + compileFilesInDir("../tests/pos-special/spec-t5545", defaultOptions) + compileFilesInDir("../tests/pos-special/strawman-collections", defaultOptions) + compileFile("../scala2-library/src/library/scala/collection/immutable/IndexedSeq.scala", defaultOptions) + @@ -110,6 +109,7 @@ class CompilationTests extends ParallelTesting { implicit val testGroup: TestGroup = TestGroup("posTwice") compileFile("../tests/pos/Labels.scala", defaultOptions) + compileFilesInDir("../tests/pos-java-interop", defaultOptions) + + compileFilesInDir("../tests/pos-java-interop-separate", defaultOptions) + compileFile("../tests/pos/t2168.scala", defaultOptions) + compileFile("../tests/pos/erasure.scala", defaultOptions) + compileFile("../tests/pos/Coder.scala", defaultOptions) + diff --git a/tests/pos-special/i3273/test/Bar_1.java b/tests/pos-java-interop-separate/i3273/Bar_1.java similarity index 100% rename from tests/pos-special/i3273/test/Bar_1.java rename to tests/pos-java-interop-separate/i3273/Bar_1.java diff --git a/tests/pos-special/i3273/test/client_2.scala b/tests/pos-java-interop-separate/i3273/client_2.scala similarity index 100% rename from tests/pos-special/i3273/test/client_2.scala rename to tests/pos-java-interop-separate/i3273/client_2.scala From d19a792f1cd0d4dd012bec98efbe3178d5049cf6 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Thu, 4 Jan 2018 22:38:30 +0100 Subject: [PATCH 2/2] 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. --- .../dotty/tools/dotc/core/classfile/ClassfileParser.scala | 7 ++++--- compiler/test/dotty/tools/vulpix/ParallelTesting.scala | 5 ++++- tests/pos-java-interop-separate/i3533/Test_2.scala | 3 +++ .../pos-java-interop-separate/i3533/TryMe_JAVA_ONLY_1.java | 6 ++++++ 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 tests/pos-java-interop-separate/i3533/Test_2.scala create mode 100644 tests/pos-java-interop-separate/i3533/TryMe_JAVA_ONLY_1.java diff --git a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala index 7909413e36fb..55b2f2ae4c8f 100644 --- a/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala +++ b/compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala @@ -161,7 +161,7 @@ class ClassfileParser( for (i <- 0 until in.nextChar) parseMember(method = false) for (i <- 0 until in.nextChar) parseMember(method = true) - classInfo = cook.apply(parseAttributes(classRoot.symbol, classInfo)) + classInfo = parseAttributes(classRoot.symbol, classInfo) if (isAnnotation) addAnnotationConstructor(classInfo) val companionClassMethod = ctx.synthesizeCompanionMethod(nme.COMPANION_CLASS_METHOD, classRoot, moduleRoot) @@ -261,7 +261,7 @@ class ClassfileParser( addConstructorTypeParams(denot) } - denot.info = cook.apply(pool.getType(in.nextChar)) + denot.info = pool.getType(in.nextChar) if (isEnum) denot.info = ConstantType(Constant(sym)) if (isConstructor) normalizeConstructorParams() setPrivateWithin(denot, jflags) @@ -625,7 +625,8 @@ class ClassfileParser( for (i <- 0 until in.nextChar) { parseAttribute() } - newType + + cook.apply(newType) } /** Add synthetic constructor(s) and potentially also default getters which diff --git a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala index 48dcd42a96eb..062eb929e3e8 100644 --- a/compiler/test/dotty/tools/vulpix/ParallelTesting.scala +++ b/compiler/test/dotty/tools/vulpix/ParallelTesting.scala @@ -376,7 +376,10 @@ trait ParallelTesting extends RunnerOrchestration { self => // Compile with a try to catch any StackTrace generated by the compiler: try { - driver.process(allArgs ++ files.map(_.getAbsolutePath), reporter = reporter) + // If a test contains a Java file that cannot be parsed by Dotty's Java source parser, its + // name must contain the string "JAVA_ONLY". + val dottyFiles = files.filterNot(_.getName.contains("JAVA_ONLY")).map(_.getAbsolutePath) + driver.process(allArgs ++ dottyFiles, reporter = reporter) val javaFiles = files.filter(_.getName.endsWith(".java")).map(_.getAbsolutePath) val javaErrors = compileWithJavac(javaFiles) diff --git a/tests/pos-java-interop-separate/i3533/Test_2.scala b/tests/pos-java-interop-separate/i3533/Test_2.scala new file mode 100644 index 000000000000..02819f8aac2a --- /dev/null +++ b/tests/pos-java-interop-separate/i3533/Test_2.scala @@ -0,0 +1,3 @@ +object Test { + TryMe_JAVA_ONLY_1.ifYouCan(list => list.size()) +} diff --git a/tests/pos-java-interop-separate/i3533/TryMe_JAVA_ONLY_1.java b/tests/pos-java-interop-separate/i3533/TryMe_JAVA_ONLY_1.java new file mode 100644 index 000000000000..14fbbd32e777 --- /dev/null +++ b/tests/pos-java-interop-separate/i3533/TryMe_JAVA_ONLY_1.java @@ -0,0 +1,6 @@ +import java.util.function.Function; + +public class TryMe_JAVA_ONLY_1 { + public static void ifYouCan(Function f) { + } +}