From a8b6e361de37705036c4e8307ad75e279fafe9f5 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Mon, 19 Jan 2015 21:40:20 +0100 Subject: SI-9097 Remove spurious warning about conflicting filenames When using delambdafy:method, closure classes are generated late. The class is added to a map and integrated into the PackageDef in transformStats. When declaring a package object, there are potentially multiple PackageDefs for the same package. In this case, the closure class was added to all of them. As a result, GenASM / GenBCode would run multiple times on the closure class. In GenBCode this would trigger a warning about conflicting filenames. --- test/files/pos/t9097.flags | 1 + test/files/pos/t9097.scala | 9 +++++++++ test/files/run/t9097.scala | 26 ++++++++++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 test/files/pos/t9097.flags create mode 100644 test/files/pos/t9097.scala create mode 100644 test/files/run/t9097.scala (limited to 'test/files') diff --git a/test/files/pos/t9097.flags b/test/files/pos/t9097.flags new file mode 100644 index 0000000000..0f8175b88b --- /dev/null +++ b/test/files/pos/t9097.flags @@ -0,0 +1 @@ +-Ydelambdafy:method -Ybackend:GenBCode -Xfatal-warnings \ No newline at end of file diff --git a/test/files/pos/t9097.scala b/test/files/pos/t9097.scala new file mode 100644 index 0000000000..5e0e921271 --- /dev/null +++ b/test/files/pos/t9097.scala @@ -0,0 +1,9 @@ +package o +package a { + class C { + def hihi = List(1,2).map(_ * 2) + } +} +package object a { + def f = 1 +} diff --git a/test/files/run/t9097.scala b/test/files/run/t9097.scala new file mode 100644 index 0000000000..0f148c3b9d --- /dev/null +++ b/test/files/run/t9097.scala @@ -0,0 +1,26 @@ +import scala.tools.partest._ +import java.io.{Console => _, _} + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp -Ydelambdafy:method -Xprint:delambdafy -d " + testOutput.path + + override def code = """package o + |package a { + | class C { + | def hihi = List(1,2).map(_ * 2) + | } + |} + |package object a { + | def f = 1 + |} + |""".stripMargin.trim + + override def show(): Unit = { + val baos = new java.io.ByteArrayOutputStream() + Console.withOut(baos)(Console.withErr(baos)(compile())) + val out = baos.toString("UTF-8") + // was 2 before the fix, the two PackageDefs for a would both contain the ClassDef for the closure + assert(out.lines.count(_ contains "class hihi$1") == 1, out) + } +} -- cgit v1.2.3