-
Notifications
You must be signed in to change notification settings - Fork 191
Open
Description
I found that ExplicitResultTypes will silently do nothing when there is a problem with the classpath. In my particular case my classpath had:
scala-compiler-2.13.14.jar, scala-reflect-2.13.16.jar, and scalafix-reflect_2.13.14-0.12.1.jar, basically the incorrect scala-reflect for the version of scalafix I am using.
Fixing scala-reflect to be 2.13.14 fixed the issue.
What helped was enabling fatalWarnings:
ExplicitResultTypes.fatalWarnings = true
With this on, ScalaFix did crash and report an error:
info: Processing (0/1) /.../MyFile.scala
scalafix.internal.v1.FileException: unexpected error processing file /.../MyFile.scala
Caused by: scalafix.internal.rule.CompilerException: compiler crashed
at scalafix.internal.rule.CompilerTypePrinter.toPatch(CompilerTypePrinter.scala:36)
at scalafix.internal.rule.ExplicitResultTypes.$anonfun$defnType$2(ExplicitResultTypes.scala:204)
...
Caused by: java.lang.NoClassDefFoundError: scala/reflect/internal/tpe/TypeMaps$ContainsAnyCollector
at scala.tools.nsc.typechecker.Typers$Typer.<init>(Typers.scala:211)
at scala.tools.nsc.interactive.InteractiveAnalyzer$$anon$1.<init>(Global.scala:50)
at scala.tools.nsc.interactive.InteractiveAnalyzer.newTyper(Global.scala:50)
...
Caused by: java.lang.ClassNotFoundException: scala.reflect.internal.tpe.TypeMaps$ContainsAnyCollector
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 71 more
The key being here that scala/reflect/internal/tpe/TypeMaps$ContainsAnyCollector exists in scala-reflect 2.13.14 but not scala-reflect 2.13.16.
Thanks to @bjaglin for advice on Discord that helped me figure this out!