com-lihaoyi / acyclic

Acyclic is a Scala compiler plugin to let you prohibit circular dependencies between files
MIT License
250 stars 34 forks source link

Breaks sbt console #34

Open ghostbuster91 opened 4 years ago

ghostbuster91 commented 4 years ago

When using acyclic with settings

    lazy val acyclicSettings = Seq(
      libraryDependencies += "com.lihaoyi" %% "acyclic" % acyclicVersion.value % "provided",
      autoCompilerPlugins := true,
      scalacOptions += "-P:acyclic:force",
      libraryDependencies += compilerPlugin("com.lihaoyi" %% "acyclic" % acyclicVersion.value)
    )

Sbt console crashes with

[IJ]sbt:proj1> console
[info] Starting scala interpreter...
Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 1.8.0_232).
Type in expressions for evaluation. Or try :help.

scala> val a = 1
java.util.NoSuchElementException: key not found: <console>
    at scala.collection.immutable.Map$Map1.apply(Map.scala:240)
    at acyclic.plugin.PluginPhase$$anon$1.$anonfun$run$8(PluginPhase.scala:96)
    at scala.collection.IterableOps.groupBy(Iterable.scala:557)
    at scala.collection.IterableOps.groupBy$(Iterable.scala:552)
    at scala.collection.AbstractIterable.groupBy(Iterable.scala:921)
    at acyclic.plugin.PluginPhase$$anon$1.$anonfun$run$2(PluginPhase.scala:96)
    at scala.collection.immutable.List.map(List.scala:219)
    at scala.collection.immutable.List.map(List.scala:79)
    at acyclic.plugin.PluginPhase$$anon$1.run(PluginPhase.scala:83)
    at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1506)
    at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1490)
    at scala.tools.nsc.interpreter.IMain$ReadEvalPrint.compile(IMain.scala:704)
    at scala.tools.nsc.interpreter.IMain$Request.$anonfun$compile$7(IMain.scala:913)
    at scala.runtime.java8.JFunction0$mcZ$sp.apply(JFunction0$mcZ$sp.scala:17)
    at scala.tools.nsc.interpreter.IMain.$anonfun$withoutWarnings$1(IMain.scala:1334)
    at scala.tools.nsc.interpreter.shell.ReplReporterImpl.withoutPrintingResults(Reporter.scala:64)
    at scala.tools.nsc.interpreter.IMain.withoutWarnings(IMain.scala:99)
    at scala.tools.nsc.interpreter.IMain$Request.compile(IMain.scala:913)
    at scala.tools.nsc.interpreter.IMain.compile(IMain.scala:493)
    at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:487)
    at scala.tools.nsc.interpreter.IMain.interpret(IMain.scala:470)
    at scala.tools.nsc.interpreter.shell.ILoop.interpretStartingWith(ILoop.scala:931)
    at scala.tools.nsc.interpreter.shell.ILoop.command(ILoop.scala:788)
    at scala.tools.nsc.interpreter.shell.ILoop.processLine(ILoop.scala:462)
    at scala.tools.nsc.interpreter.shell.ILoop.loop(ILoop.scala:485)
    at scala.tools.nsc.interpreter.shell.ILoop.run(ILoop.scala:1020)
    at xsbt.ConsoleInterface.run(ConsoleInterface.scala:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sbt.internal.inc.AnalyzingCompiler.call(AnalyzingCompiler.scala:248)
    at sbt.internal.inc.AnalyzingCompiler.console(AnalyzingCompiler.scala:210)
    at sbt.Console.console0$1(Console.scala:48)
    at sbt.Console.$anonfun$apply$2(Console.scala:51)
    at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
    at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:10)
    at sbt.TrapExit$App.run(TrapExit.scala:257)
    at java.lang.Thread.run(Thread.java:748)

That entry seems to have slain the compiler.  Shall I replay
your session? I can re-run each line except the last one.
[y/n]

sbt version 1.3.4

jtjeferreira commented 2 years ago

Workaround is the compiler plugin from the console configuration

scalacOptions in (Compile, console) ~= { _.filterNot(_.startsWith("-Xplugin")) }, //this will remove all compiler plugins