From 1730d8aedf17c4730b8c1810b0d2a825a2f64914 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 19 Nov 2024 04:34:53 -0500 Subject: [PATCH] fix: Remove "One of these files" error **Problem** See gh-21973. Currently the ambiguous symbol detection raises false positives when used together with `-Wunused:imports`. **Solution** Remove the faulty ambiguous symbol detection for now. --- .../src/dotty/tools/dotc/core/SymDenotations.scala | 3 --- sbt-test/jar-dependencies/jar/a/A.scala | 6 ++++++ sbt-test/jar-dependencies/jar/b/B.scala | 3 +++ sbt-test/jar-dependencies/jar/build.sbt | 8 ++++++++ .../jar/project/DottyInjectedPlugin.scala | 12 ++++++++++++ sbt-test/jar-dependencies/jar/test | 3 +++ 6 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 sbt-test/jar-dependencies/jar/a/A.scala create mode 100644 sbt-test/jar-dependencies/jar/b/B.scala create mode 100644 sbt-test/jar-dependencies/jar/build.sbt create mode 100644 sbt-test/jar-dependencies/jar/project/DottyInjectedPlugin.scala create mode 100644 sbt-test/jar-dependencies/jar/test diff --git a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala index f54b8a62fa25..1a3d7fb81d17 100644 --- a/compiler/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/compiler/src/dotty/tools/dotc/core/SymDenotations.scala @@ -2552,9 +2552,6 @@ object SymDenotations { | $chosen |and also in | $f""" - if youngest.size > 1 then - throw TypeError(em"""${ambiguousFilesMsg(youngest.tail.head)} - |One of these files should be removed from the classpath.""") // Warn if one of the older files comes from a different container. // In that case picking the youngest file is not necessarily what we want, diff --git a/sbt-test/jar-dependencies/jar/a/A.scala b/sbt-test/jar-dependencies/jar/a/A.scala new file mode 100644 index 000000000000..5c6b224b4f3c --- /dev/null +++ b/sbt-test/jar-dependencies/jar/a/A.scala @@ -0,0 +1,6 @@ +package example: + trait A: + def foo: String = ??? + +package object example extends A: + def foo(x: String): String = ??? diff --git a/sbt-test/jar-dependencies/jar/b/B.scala b/sbt-test/jar-dependencies/jar/b/B.scala new file mode 100644 index 000000000000..c32bf972949b --- /dev/null +++ b/sbt-test/jar-dependencies/jar/b/B.scala @@ -0,0 +1,3 @@ +import example.* + +@main def main = foo diff --git a/sbt-test/jar-dependencies/jar/build.sbt b/sbt-test/jar-dependencies/jar/build.sbt new file mode 100644 index 000000000000..75754c9ece3e --- /dev/null +++ b/sbt-test/jar-dependencies/jar/build.sbt @@ -0,0 +1,8 @@ +ThisBuild / organization := "com.example" + +lazy val a = project + +lazy val b = project + .settings( + Compile / unmanagedJars += (a / Compile / packageBin).map(Attributed.blank).value + ) diff --git a/sbt-test/jar-dependencies/jar/project/DottyInjectedPlugin.scala b/sbt-test/jar-dependencies/jar/project/DottyInjectedPlugin.scala new file mode 100644 index 000000000000..b85c4f478ad7 --- /dev/null +++ b/sbt-test/jar-dependencies/jar/project/DottyInjectedPlugin.scala @@ -0,0 +1,12 @@ +import sbt._ +import Keys._ + +object DottyInjectedPlugin extends AutoPlugin { + override def requires = plugins.JvmPlugin + override def trigger = allRequirements + + override val projectSettings = Seq( + scalaVersion := sys.props("plugin.scalaVersion"), + scalacOptions ++= List("-Werror", "-Wunused:imports"), + ) +} diff --git a/sbt-test/jar-dependencies/jar/test b/sbt-test/jar-dependencies/jar/test new file mode 100644 index 000000000000..a9d03178fccb --- /dev/null +++ b/sbt-test/jar-dependencies/jar/test @@ -0,0 +1,3 @@ +# https://github.com/scala/scala3/issues/17394 + +> b/compile