Skip to content

Commit

Permalink
fixup! Catch ClassFormatErrors in ScalacInvoker
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaden Peterson committed Jan 22, 2025
1 parent cc2f0d8 commit 3258ccb
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions src/java/io/bazel/rulesscala/scalac/ScalacWorker.java
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ private static String[] getPluginParamsFrom(CompileOptions ops) {
}
if (ops.directTargets.length > 0) {
pluginParams.add(
"-P:dependency-analyzer:direct-targets:" + encodeStringSeqPluginParam(ops.directTargets));
"-P:dependency-analyzer:direct-targets:" + encodeStringSeqPluginParam(ops.directTargets));
}
if (ops.indirectJars.length > 0) {
pluginParams.add(
Expand Down Expand Up @@ -269,20 +269,7 @@ private static void compileScalaSources(CompileOptions ops, String[] scalaSource
String[] compilerArgs =
merge(ops.scalaOpts, pluginArgs, constParams, pluginParams, scalaSources);

ScalacInvokerResults compilerResults;

try {
compilerResults = ScalacInvoker.invokeCompiler(ops, compilerArgs);
} catch (CompilationFailed exception) {
if (exception.getCause() instanceof ClassFormatError) {
throw new Exception(
"You may have declared a target containing a macro as a `scala_library` target instead of a `scala_macro_library` target.",
exception
);
}

throw exception;
}
ScalacInvokerResults compilerResults = ScalacInvoker.invokeCompiler(ops, compilerArgs);

if (ops.printCompileTime) {
System.err.println("Compiler runtime: " + (compilerResults.stopTime - compilerResults.startTime) + "ms.");
Expand Down

0 comments on commit 3258ccb

Please sign in to comment.