Closed
Description
Compiler version
3.3.0-RC5
Minimized code
Project 1 - the library
//file AppliedBuilder.scala
package repro
import repro.internal.*
final class AppliedBuilder[Source, Dest](appliedTo: Source) {
inline def transform: Dest = ReproObject.doNothing
}
//file Extension1.scala
package repro
import repro.internal.*
extension (source: Int) inline def whatever1 = ReproObject.doNothing
//file Extension2.scala
package repro
import repro.internal.*
extension (source: Int) inline def whatever2 = ReproObject.doNothing
//file ReproObject.scala
package repro.internal
private[repro] object ReproObject {
inline def doNothing = ???
}
//file syntax.scala
package repro
extension [Source](source: Source) {
def into[Dest]: AppliedBuilder[Source, Dest] = AppliedBuilder[Source, Dest](source)
}
//file project.scala
//> using scala "3.2.2"
//> using publish.organization "repro"
//> using publish.name "repro"
//> using publish.version "0.1.0"
Project 2 - usage site, depends on 'Project 1'
//file usage.scala
//> using scala "3.3.0-RC5"
//> using option "-Wunused:all"
//> using dep "repro::repro:0.1.0"
import repro.*
@main def main = "whatever".into[Int].transform
To reproduce 'Project 1' needs to be published first:
scala-cli --power publish local .
then we can just run the second project with:
scala-cli compile .
Output
aleksander@pop-os:~/repos/wunused-usage-repro$ scala-cli compile .
Compiling project (Scala 3.3.0-RC5, JVM)
exception occurred while compiling /home/aleksander/repos/wunused-usage-repro/usage.scala
Error compiling project (Scala 3.3.0-RC5, JVM)
Error: Unexpected error when compiling project_dd4f5f0c18: 'Toplevel definition inline$ReproObject$i1 is defined in
/home/aleksander/.ivy2/local/repro/repro_3/0.1.0/jars/repro_3.jar(repro/Extension1$package.class)
and also in
/home/aleksander/.ivy2/local/repro/repro_3/0.1.0/jars/repro_3.jar(repro/Extension2$package.class)
One of these files should be removed from the classpath.'
Compilation failed
Expectation
Compilation succeeds just like it does without -Wunused:all
Context
This issue was first reported here: arainko/ducktape#54 - a workaround for it was moving the contents of fallibleSyntax.scala to syntax.scala, that way another inline accessor for Transformations
(with the name inline$Transformations$i1
) is not generated, a new inline$Transformations$i3
accessor is generated instead, because these are now in the scope of the same class (syntax$package
).
For the sake of completeness, here's a definition of Transformations
, this file houses proxies to macros, it's also package private.