Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error compiling in IntelliJ with dependency on Scala 3.4 #41

Open
matmannion opened this issue Jul 5, 2024 · 0 comments
Open

Error compiling in IntelliJ with dependency on Scala 3.4 #41

matmannion opened this issue Jul 5, 2024 · 0 comments

Comments

@matmannion
Copy link

matmannion commented Jul 5, 2024

This is a weird one and I'm pretty sure it's actually a bug with the IntelliJ Scala plugin (raised as https://youtrack.jetbrains.com/issue/SCL-22833/Error-compiling-in-IntelliJ-with-play-brotli-filter-dependency-on-Scala-3.4), but thought I would raise here in case it rings any bells. On any project that uses this library as a dependency, it will fail to compile on IntelliJ using Scala 3.4.0 or later if there is any use of implicits in the project.

Minimal reproduction case: https://github.com/matmannion/scala-3.4-play-brotli-filter-ij

It still compiles fine with sbt compile, but using the IntelliJ compiler it throws an error:

Executing pre-compile tasks…
Running 'before' tasks
Checking sources
Searching for compilable files... [tests of root]
Checking dependencies… [root]
Dependency analysis found 0 affected files
Updating dependency information… [root]
Searching for compilable files... [root]
Reading compilation settings... [root]
Compiling... [root]
scala: compiling 1 Scala source to /Users/mat/code/test/target/scala-3.4.2/classes ...
scala: 
  unhandled exception while running MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, checkStatic, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher} on /Users/mat/code/test/src/main/scala/Test.scala

  An unhandled exception was thrown in the compiler.
  Please file a crash report here:
  https://github.com/scala/scala3/issues/new/choose
  For non-enriched exceptions, compile with -Yno-enrich-error-messages.

     while compiling: /Users/mat/code/test/src/main/scala/Test.scala
        during phase: MegaPhase{protectedAccessors, extmethods, uncacheGivenAliases, checkStatic, elimByName, hoistSuperArgs, forwardDepChecks, specializeApplyMethods, tryCatchPatterns, patternMatcher}
                mode: Mode(ImplicitsEnabled)
     library version: version 2.13.12
    compiler version: version 3.4.2
            settings: -classpath /Users/mat/code/test/target/scala-3.4.2/classes:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/aayushatharva/brotli4j/brotli4j/1.16.0/brotli4j-1.16.0.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/aayushatharva/brotli4j/native-osx-aarch64/1.16.0/native-osx-aarch64-1.16.0.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/aayushatharva/brotli4j/service/1.16.0/service-1.16.0.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/gu/brotli4s_3/0.16.1/brotli4s_3-0.16.1.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/gu/pekko-stream-brotli_3/0.16.1/pekko-stream-brotli_3-0.16.1.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/gu/play-v30-brotli-filter_3/0.16.1/play-v30-brotli-filter_3-0.16.1.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala-library/2.13.12/scala-library-2.13.12.jar:/Users/mat/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/scala-lang/scala3-library_3/3.4.2/scala3-library_3-3.4.2.jar -d /Users/mat/code/test/target/scala-3.4.2/classes

scala: ## Exception when compiling 1 sources to /Users/mat/code/test/target/scala-3.4.2/classes
dotty.tools.dotc.core.TypeError$$anon$1: object caps does not have a member type Cap

           
scala: Compilation failed when compiling to: /Users/mat/code/test/target/scala-3.4.2/classes
  object caps does not have a member type Cap
  
Errors occurred while compiling module 'root'
Finished, saving caches…
Module 'root.root-build' was fully rebuilt due to project configuration/dependencies changes
Builder Scala sbt builder requested build stop
Executing post-compile tasks…
Synchronizing output directories…
05/07/2024, 12:01 - Build completed with 2 errors and 1 warning in 1 sec, 177 ms

That error seems to be related to multiple versions of scala-library being in the classpath, but there definitely isn't multiple versions in the classpath (as can be seen in the settings, it just has the 3.4.2 version and the 2.3.12 version which is completely normal for a Scala 3 compile).

It works fine if the library is removed from the classpath, the Scala version is dropped to a 3.3.x version or if the code has no use of implicits so it never enters the implicits phase of the compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant