Giter Site home page Giter Site logo

classpath-shrinker's People

Contributors

jvican avatar retronym avatar shvar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

classpath-shrinker's Issues

Macro classpath entries are flagged as unused

Hi everyone,

I am currently working on trying out the classpath-shrinker plugin with our codebase. I ran into an issue in which the plugin warns about certain used classpath entries as unused. The classpath entries warned about contain macros. If you remove the classpath entries that are flagged as unused, the code no longer compiles.

I created a repro example here: https://github.com/lucidsoftware/classpath-shrinker-example1

In this example, I have a simple source file

package foo

object Foo {
  def main(args: Array[String]): Unit = {
    import cats.implicits._
    println(true === false)
  }
}

that compiles under both Scala 2.11 and 2.12 and warns about unused classpath entries:

2.11:

james@james:~/opensource/classpath-shrinker-example1$ ./compile.sh /home/james/Desktop/scala-2.11.12/bin/scalac 2-11 macro
/home/james/Desktop/scala-2.11.12/bin/scalac -Xplugin:2-11-cp-shrinker/classpath-shrinker_2.11-0.1.1.jar -cp 2-11/cats-core_2.11-1.0.1.jar:2-11/cats-kernel_2.11-1.0.1.jar:2-11-macro/cats-macros_2.11-1.0.1.jar:2-11-macro/machinist_2.11-0.6.1.jar Foo.scala
cat: /release: No such file or directory
warning: Detected the following unused classpath entries:
/home/james/opensource/classpath-shrinker-example1/2-11-macro/cats-macros_2.11-1.0.1.jar
/home/james/opensource/classpath-shrinker-example1/2-11-macro/machinist_2.11-0.6.1.jar
one warning found

2.12:

james@james:~/opensource/classpath-shrinker-example1$ ./compile.sh /home/james/Desktop/scala-2.12.4/bin/scalac 2-12 macro
/home/james/Desktop/scala-2.12.4/bin/scalac -Xplugin:2-12-cp-shrinker/classpath-shrinker_2.12-0.1.1.jar -cp 2-12/cats-core_2.12-1.0.1.jar:2-12/cats-kernel_2.12-1.0.1.jar:2-12-macro/cats-macros_2.12-1.0.1.jar:2-12-macro/machinist_2.12-0.6.2.jar Foo.scala
warning: Detected the following unused classpath entries:
/home/james/opensource/classpath-shrinker-example1/2-12-macro/cats-macros_2.12-1.0.1.jar
/home/james/opensource/classpath-shrinker-example1/2-12-macro/machinist_2.12-0.6.2.jar
one warning found

If I remove those classpath entries, then both 2.11 and 2.12 fail to compile:

2.11:

james@james:~/opensource/classpath-shrinker-example1$ ./compile.sh /home/james/Desktop/scala-2.11.12/bin/scalac 2-11 nomacro
/home/james/Desktop/scala-2.11.12/bin/scalac -Xplugin:2-11-cp-shrinker/classpath-shrinker_2.11-0.1.1.jar -cp 2-11/cats-core_2.11-1.0.1.jar:2-11/cats-kernel_2.11-1.0.1.jar Foo.scala
cat: /release: No such file or directory
Foo.scala:6: error: macro implementation not found: $eq$eq$eq
(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)
    println(true === false)
                 ^
one error found

2.12:

james@james:~/opensource/classpath-shrinker-example1$ ./compile.sh /home/james/Desktop/scala-2.12.4/bin/scalac 2-12 nomacro
/home/james/Desktop/scala-2.12.4/bin/scalac -Xplugin:2-12-cp-shrinker/classpath-shrinker_2.12-0.1.1.jar -cp 2-12/cats-core_2.12-1.0.1.jar:2-12/cats-kernel_2.12-1.0.1.jar Foo.scala
Foo.scala:6: error: macro implementation not found: $eq$eq$eq
(the most common reason for that is that you cannot use macro implementations in the same compilation run that defines them)
    println(true === false)
                 ^
one error found

My knowledge of the Scala compiler is not very good. I've been poking at the plugin and the Scala source without much luck. Anyone have any guidance or recommendations?

Thanks in advance for the help!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.