java.lang.NullPointerException in scalac

I have some code which triggers a java.lang.NullPointerException in scalac. Should I try to submit a bug report with a minimum working example (MWE). Or is this type of thing of no real interest to the compiler developers?
Or is this a bug in the jet brains plugin, better reported to IntelliJ?

I can probably easily fix my code to avoid the issue.

Error:scalac: Error: org.jetbrains.jps.incremental.scala.remote.ServerException
java.lang.NullPointerException
	at scala.reflect.internal.Types$TypeRef.computeHashCode(Types.scala:2146)
	at scala.reflect.internal.Types$UniqueType.<init>(Types.scala:1078)
	at scala.reflect.internal.Types$TypeRef.<init>(Types.scala:2108)
	at scala.reflect.internal.Types$ArgsTypeRef.<init>(Types.scala:1870)
	at scala.reflect.internal.Types$ClassArgsTypeRef.<init>(Types.scala:2437)
	at scala.reflect.internal.Types$TypeRef$.apply(Types.scala:2447)
	at scala.reflect.internal.Types.copyTypeRef(Types.scala:3673)
	at scala.reflect.internal.Types.copyTypeRef$(Types.scala:3665)
	at scala.reflect.internal.SymbolTable.copyTypeRef(SymbolTable.scala:27)
	at scala.reflect.internal.Types.appliedType(Types.scala:3749)
	at scala.reflect.internal.Types.appliedType$(Types.scala:3734)
	at scala.reflect.internal.SymbolTable.appliedType(SymbolTable.scala:27)
	at scala.reflect.internal.Types.appliedType(Types.scala:3767)
	at scala.reflect.internal.Types.appliedType$(Types.scala:3766)
	at scala.reflect.internal.SymbolTable.appliedType(SymbolTable.scala:27)
	at scala.reflect.internal.Definitions$DefinitionsClass$VarArityClass.specificType(Definitions.scala:602)
	at scala.reflect.internal.Definitions$DefinitionsClass.functionType(Definitions.scala:620)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedFunctionUndoingEtaExpansion$6(Typers.scala:3153)
	at scala.tools.nsc.typechecker.Typers$Typer.typedFunctionUndoingEtaExpansion(Typers.scala:73)
	at scala.tools.nsc.typechecker.Typers$Typer.typedFunction(Typers.scala:3049)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$97(Typers.scala:5621)
	at scala.tools.nsc.typechecker.Typers$Typer.typedFunction$1(Typers.scala:500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5658)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5690)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedArg$1(Typers.scala:3389)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:491)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArgToPoly$1(Typers.scala:3779)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$doTypedApply$33(Typers.scala:3787)
	at scala.tools.nsc.typechecker.Typers$Typer.handlePolymorphicCall$1(Typers.scala:3787)
	at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3798)
	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4876)
	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4885)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5680)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.doTypedFunction(Typers.scala:5801)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedFunction$2(Typers.scala:3058)
	at scala.reflect.internal.Trees$TreeContextApiImpl.orElse(Trees.scala:113)
	at scala.tools.nsc.typechecker.Typers$Typer.typedFunction(Typers.scala:3049)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$97(Typers.scala:5621)
	at scala.tools.nsc.typechecker.Typers$Typer.typedFunction$1(Typers.scala:500)
	at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5658)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5690)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedArg$1(Typers.scala:3389)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArg(Typers.scala:491)
	at scala.tools.nsc.typechecker.Typers$Typer.typedArgToPoly$1(Typers.scala:3779)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$doTypedApply$33(Typers.scala:3787)
	at scala.tools.nsc.typechecker.Typers$Typer.handlePolymorphicCall$1(Typers.scala:3787)
	at scala.tools.nsc.typechecker.Typers$Typer.doTypedApply(Typers.scala:3798)
	at scala.tools.nsc.typechecker.Typers$Typer.normalTypedApply$1(Typers.scala:4876)
	at scala.tools.nsc.typechecker.Typers$Typer.typedApply$1(Typers.scala:4885)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5680)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.typedCase(Typers.scala:5801)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedCases$1(Typers.scala:2579)
	at scala.tools.nsc.typechecker.Typers$Typer.typedCases(Typers.scala:2578)
	at scala.tools.nsc.typechecker.Typers$Typer.typedMatch(Typers.scala:2590)
	at scala.tools.nsc.typechecker.Typers$Typer.typedVirtualizedMatch$1(Typers.scala:4585)
	at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:5659)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5690)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.typedBlock(Typers.scala:2504)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typed1$98(Typers.scala:5655)
	at scala.tools.nsc.typechecker.Typers$Typer.typedOutsidePatternMode$1(Typers.scala:500)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5690)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.typedDefDef(Typers.scala:5942)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5645)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:5790)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3373)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3373)
	at scala.tools.nsc.typechecker.Typers$Typer.typedTemplate(Typers.scala:2030)
	at scala.tools.nsc.typechecker.Typers$Typer.typedClassDef(Typers.scala:1843)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5646)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStat$1(Typers.scala:5790)
	at scala.tools.nsc.typechecker.Typers$Typer.$anonfun$typedStats$10(Typers.scala:3373)
	at scala.tools.nsc.typechecker.Typers$Typer.typedStats(Typers.scala:3373)
	at scala.tools.nsc.typechecker.Typers$Typer.typedPackageDef$1(Typers.scala:5356)
	at scala.tools.nsc.typechecker.Typers$Typer.typed1(Typers.scala:5649)
	at scala.tools.nsc.typechecker.Typers$Typer.typed(Typers.scala:5726)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$TyperPhase.apply(Analyzer.scala:114)
	at scala.tools.nsc.Global$GlobalPhase.applyPhase(Global.scala:448)
	at scala.tools.nsc.typechecker.Analyzer$typerFactory$TyperPhase.run(Analyzer.scala:103)
	at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1498)
	at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1482)
	at scala.tools.nsc.Global$Run.compileSources(Global.scala:1475)
	at scala.tools.nsc.Global$Run.compile(Global.scala:1598)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:130)
	at xsbt.CachedCompiler0.run(CompilerInterface.scala:105)
	at xsbt.CompilerInterface.run(CompilerInterface.scala:31)
	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:237)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:111)
	at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:90)
	at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:40)
	at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:35)
	at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:83)
	at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:26)
	at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
	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 com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)```

This could of course be something in my IntelliJ environment, not ruling that out, but now when i compile, I no longer get the scalac stacktrace, but just the NullPointException error message. Is this normal?

When I paste a reduced version of the code onto Scastie, it tersely reports the error, but doesn’t seem to crash the compiler. https://scastie.scala-lang.org/jimka2001/RE5h9qDnQD6I1frr23XVVw/3

Seems likely worth minimizing and reporting the bug, but where to report depends on the recipe. If it repros in sbt, then it’s a Scala bug and should be reported in scala/scala. If it only repros in IntelliJ, then it’s probably an IDEA bug and should be reported to JetBrains. (I suspect the latter, given the exception, but can’t say for certain.)

The problems is somewhat reproducible on Scastie. @martijnhoekstra reports seeing the stacktrace, but i don’t see it myself.

I do!

Yes, I see it there as well. Thanks.

Adding the type annotations as the compiler suggests fixes the problem and avoids the null exception. So I’m off and running. Not sure what my responsibility as a good Scala citizen is in this cased.

  def reduceOne(posCount: Int, addFunction: HashUpdateFunction, removeFunction: HashUpdateFunction): Unit = {
    val posCountDec = posCount - 1
    (hash.get(posCount), hash.get(posCountDec)) match {
      case (None, _) => Unit
      case (_, None) => Unit
      case (Some(lengthHashA), Some(lengthHashB)) =>
       type B = HashMap[Clause,Set[Clause]]
        mapCommon(lengthHashA, lengthHashB, (length:Int, rectHashA:B, rectHashB:B) =>
          mapCommon(rectHashA, rectHashB, (rectified:Clause, cla:Set[Clause], clb:Set[Clause]) =>
            crossCompatiblize(cla, clb, posCount, length, rectified, removeFunction, addFunction)))
    }
  }