Skip to content

classcast error within the compiler #24319

@bbeyl-it

Description

@bbeyl-it

Compiler version

3.3.7
If you're not sure what version you're using, run print scalaVersion from sbt
(if you're running scalac manually, use scalac -version instead).

Minimized code

Can't provide due to client and time constraints

Output (click arrow to expand)


relevant part from build.sbt

   scalacOptions ++= Seq(
      // "-classpath", "foo:bar:...",         // Add to the classpath.
      "-encoding", "utf-8",                // Specify character encoding used by source files.
      "-deprecation",                      // Emit warning and location for usages of deprecated APIs.
      "-unchecked",                        // Enable additional warnings where generated code depends on assumptions.
      "-feature",                          // Emit warning and location for usages of features that should be imported explicitly.
      "-explain",                          // Explain errors in more detail.
      // "-explain-types",                    // Explain type errors in more detail.
      // "-indent",                           // Together with -rewrite, remove {...} syntax when possible due to significant indentation.
      // "-no-indent",                        // Require classical {...} syntax, indentation is not significant.
      "-new-syntax",                       // Require `then` and `do` in control expressions.
      // "-old-syntax",                       // Require `(...)` around conditions.
      // "-language:Scala2",                  // Compile Scala 2 code, highlight what needs updating
      // "-language:strictEquality",          // Require +derives Eql+ for using == or != comparisons
      // "-rewrite",                          // Attempt to fix code automatically. Use with -indent and ...-migration.
      // "-scalajs",                          // Compile in Scala.js mode (requires scalajs-library.jar on the classpath).
//      "-source:future",                       // Choices: future and future-migration. I use this to force future deprecation warnings, etc.
//      "-source:3.3-migration",                       // Choices: future and future-migration. I use this to force future deprecation warnings, etc.
//      "-Xfatal-warnings",                  // Fail on warnings, not just errors
      // "-Xmigration",                       // Warn about constructs whose behavior may have changed since version.
      // "-Ysafe-init",                       // Warn on field access before initialization
      // "-Yexplicit-nulls",                  // For explicit nulls behavior.
      // "-coverage-out", "coverage"          // Output "scoverage" metrics (new for Scala 3.2.0)
    ),
    javaOptions ++= Seq(
      "-Duser.language=en_US"
    ),
    javacOptions ++= Seq(
      "-Xlint:unchecked", "-Xlint:deprecation", // Java 8: "-Xdiags:verbose"),
      "-source", "21", "target", "21",
    ),

[info]   exception occurred while typechecking /home/.../scala/.../src/test/scala/eet/core/collection/interval/IntervalSpec.scala
[info] 
[info]   An unhandled exception was thrown in the compiler.
[info]   Please file a crash report here:
[info]   https://github.com/scala/scala3/issues/new/choose
[info]   For non-enriched exceptions, compile with -Xno-enrich-error-messages.
[info] 
[info] 
[info]      while compiling: /home/bbeyl/customer/uniper/projects/scala/eet-core/1.4/src/test/scala/eet/core/collection/interval/IntervalSpec.scala
[info]         during phase: typer
[info]                 mode: Mode(ImplicitsEnabled)
[info]      library version: version 2.13.16
[info]     compiler version: version 3.3.7
[info]             settings: -classpath /home/bbeyl/customer/uniper/projects/scala/eet-core/1.4/target/scala-3.3.7/test-classes:/home/bbeyl/customer/uniper/projects/scala/eet-core/1.4/target/scala-3.3.7/classes:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scala-lang/scala3-library_3/3.3.7/scala3-library_3-3.3.7.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/joda-time/joda-time/2.14.0/joda-time-2.14.0.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/joda/joda-convert/3.0.1/joda-convert-3.0.1.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/log4j/log4j/1.2.17/log4j-1.2.17.jar:/home/bbeyl/.m2/repository/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/apache/commons/commons-math3/3.6.1/commons-math3-3.6.1.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalactic/scalactic_3/3.2.9/scalactic_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scala-lang/modules/scala-xml_3/2.0.1/scala-xml_3-2.0.1.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest_3/3.2.9/scalatest_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scala-lang/scala-library/2.13.16/scala-library-2.13.16.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-core_3/3.2.9/scalatest-core_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-featurespec_3/3.2.9/scalatest-featurespec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-flatspec_3/3.2.9/scalatest-flatspec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-freespec_3/3.2.9/scalatest-freespec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-funsuite_3/3.2.9/scalatest-funsuite_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-funspec_3/3.2.9/scalatest-funspec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-propspec_3/3.2.9/scalatest-propspec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-refspec_3/3.2.9/scalatest-refspec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-wordspec_3/3.2.9/scalatest-wordspec_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-diagrams_3/3.2.9/scalatest-diagrams_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-matchers-core_3/3.2.9/scalatest-matchers-core_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-shouldmatchers_3/3.2.9/scalatest-shouldmatchers_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-mustmatchers_3/3.2.9/scalatest-mustmatchers_3-3.2.9.jar:/home/bbeyl/customer/uniper/coursier/v1/https/uitartifactory.jfrog.io/uitartifactory/libs-release/org/scalatest/scalatest-compatible/3.2.9/scalatest-compatible-3.2.9.jar -d /home/bbeyl/customer/uniper/projects/scala/eet-core/1.4/target/scala-3.3.7/test-classes -deprecation true -encoding utf-8 -explain true -feature true -new-syntax true
[error] ## Exception when compiling 21 sources to /home/bbeyl/customer/uniper/projects/scala/eet-core/1.4/target/scala-3.3.7/test-classes
[error] java.lang.ClassCastException: class dotty.tools.dotc.core.Types$NoType$ cannot be cast to class dotty.tools.dotc.typer.Implicits$SearchFailureType (dotty.tools.dotc.core.Types$NoType$ and dotty.tools.dotc.typer.Implicits$SearchFailureType are in unnamed module of loader sbt.internal.classpath.ClassLoaderCache$Key$CachedClassLoader @6abc0a67)
[error] dotty.tools.dotc.typer.Implicits$SearchFailure.reason(Implicits.scala:417)
[error] dotty.tools.dotc.typer.ErrorReporting$Errors.selectErrorAddendum$$anonfun$1$$anonfun$1(ErrorReporting.scala:228)
[error] scala.collection.immutable.List.foreach(List.scala:334)
[error] dotty.tools.dotc.typer.ErrorReporting$Errors.selectErrorAddendum$$anonfun$1(ErrorReporting.scala:226)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.Option.foreach(Option.scala:437)
[error] dotty.tools.dotc.typer.ErrorReporting$Errors.selectErrorAddendum(ErrorReporting.scala:225)
[error] dotty.tools.dotc.typer.TypeAssigner.addendum$1(TypeAssigner.scala:176)
[error] dotty.tools.dotc.typer.TypeAssigner.$anonfun$1(TypeAssigner.scala:179)
[error] dotty.tools.dotc.reporting.NotAMember.msg(messages.scala:382)
[error] dotty.tools.dotc.reporting.Message.message$$anonfun$1(Message.scala:341)
[error] dotty.tools.dotc.reporting.Message.inMessageContext(Message.scala:337)
[error] dotty.tools.dotc.reporting.Message.message(Message.scala:341)
[error] dotty.tools.dotc.reporting.Message.isNonSensical(Message.scala:318)
[error] dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden(HideNonSensicalMessages.scala:17)
[error] dotty.tools.dotc.reporting.HideNonSensicalMessages.isHidden$(HideNonSensicalMessages.scala:10)
[error] dotty.tools.dotc.reporting.AbstractReporter.isHidden(AbstractReporter.scala:8)
[error] dotty.tools.dotc.reporting.Reporter.issueUnconfigured(Reporter.scala:164)
[error] dotty.tools.dotc.reporting.Reporter.go$1(Reporter.scala:204)
[error] dotty.tools.dotc.reporting.Reporter.issueIfNotSuppressed(Reporter.scala:223)
[error] dotty.tools.dotc.reporting.Reporter.report(Reporter.scala:226)
[error] dotty.tools.dotc.reporting.Reporter.flush$$anonfun$1(Reporter.scala:287)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:334)
[error] dotty.tools.dotc.reporting.Reporter.flush(Reporter.scala:287)
[error] dotty.tools.dotc.core.TyperState.commit(TyperState.scala:176)
[error] dotty.tools.dotc.typer.Applications.fail$1(Applications.scala:1145)
[error] dotty.tools.dotc.typer.Applications.$anonfun$13$$anonfun$1(Applications.scala:1153)
[error] scala.Option.getOrElse(Option.scala:201)
[error] dotty.tools.dotc.typer.Applications.$anonfun$13(Applications.scala:1154)
[error] dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3441)
[error] dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:1155)
[error] dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1198)
[error] dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:403)
[error] dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:122)
[error] dotty.tools.dotc.typer.Typer.typedInfixOp(Typer.scala:3032)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3187)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3229)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3299)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3303)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3352)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3371)
[error] dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2768)
[error] dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:3136)
[error] dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:3140)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3228)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3299)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3303)
[error] dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:3325)
[error] dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3371)
[error] dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2911)
[error] dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:3181)
[error] dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:3229)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3299)
[error] dotty.tools.dotc.typer.Typer.typed(Typer.scala:3303)
[error] dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3414)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:45)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:467)
[error] dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:51)
[error] dotty.tools.dotc.typer.TyperPhase.$anonfun$4(TyperPhase.scala:97)
[error] scala.collection.Iterator$$anon$6.hasNext(Iterator.scala:479)
[error] scala.collection.Iterator$$anon$9.hasNext(Iterator.scala:583)
[error] scala.collection.immutable.List.prependedAll(List.scala:155)
[error] scala.collection.immutable.List$.from(List.scala:685)
[error] scala.collection.immutable.List$.from(List.scala:682)
[error] scala.collection.IterableOps$WithFilter.map(Iterable.scala:900)
[error] dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:96)
[error] dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:351)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1324)
[error] dotty.tools.dotc.Run.runPhases$1(Run.scala:344)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:384)
[error] dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:393)
[error] dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
[error] dotty.tools.dotc.Run.compileUnits(Run.scala:393)
[error] dotty.tools.dotc.Run.compileSources(Run.scala:297)
[error] dotty.tools.dotc.Run.compile(Run.scala:282)
[error] dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
[error] dotty.tools.xsbt.CompilerBridgeDriver.run(CompilerBridgeDriver.java:141)
[error] dotty.tools.xsbt.CompilerBridge.run(CompilerBridge.java:22)
[error] sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:91)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$7(MixedAnalyzingCompiler.scala:196)
[error] scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:252)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4(MixedAnalyzingCompiler.scala:186)
[error] sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$4$adapted(MixedAnalyzingCompiler.scala:166)
[error] sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:241)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compileScala$1(MixedAnalyzingCompiler.scala:166)
[error] sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:214)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1(IncrementalCompilerImpl.scala:542)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$1$adapted(IncrementalCompilerImpl.scala:542)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3(Incremental.scala:182)
[error] sbt.internal.inc.Incremental$.$anonfun$apply$3$adapted(Incremental.scala:180)
[error] sbt.internal.inc.Incremental$$anon$2.run(Incremental.scala:458)
[error] sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:56)
[error] sbt.internal.inc.IncrementalCommon$$anon$1.next(IncrementalCommon.scala:52)
[error] sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:264)
[error] sbt.internal.inc.Incremental$.$anonfun$incrementalCompile$8(Incremental.scala:413)
[error] sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:500)
[error] sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:400)
[error] sbt.internal.inc.Incremental$.apply(Incremental.scala:208)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:542)
[error] sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally$1(IncrementalCompilerImpl.scala:496)
[error] sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:433)
[error] sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2471)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$2(Defaults.scala:2421)
[error] sbt.internal.server.BspCompileTask$.$anonfun$compute$1(BspCompileTask.scala:41)
[error] sbt.internal.io.Retry$.sbt$internal$io$Retry$$impl(Retry.scala:114)
[error] sbt.internal.io.Retry$.io(Retry.scala:102)
[error] sbt.internal.io.Retry$.io(Retry.scala:78)
[error] sbt.internal.io.Retry$.io(Retry.scala:67)
[error] sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:41)
[error] sbt.Defaults$.$anonfun$compileIncrementalTask$1(Defaults.scala:2419)
[error] scala.Function1.$anonfun$compose$1(Function1.scala:49)
[error] sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:63)
[error] sbt.std.Transform$$anon$4.work(Transform.scala:69)
[error] sbt.Execute.$anonfun$submit$2(Execute.scala:283)
[error] sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:24)
[error] sbt.Execute.work(Execute.scala:292)
[error] sbt.Execute.$anonfun$submit$1(Execute.scala:283)
[error] sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:265)
[error] sbt.CompletionService$$anon$2.call(CompletionService.scala:65)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[error] java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[error] java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[error] java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[error] java.base/java.lang.Thread.run(Thread.java:833)
[error]            
[error] stack trace is suppressed; run last Test / compileIncremental for the full output
[error] (Test / compileIncremental) java.lang.ClassCastException: class dotty.tools.dotc.core.Types$NoType$ cannot be cast to class dotty.tools.dotc.typer.Implicits$SearchFailureType (dotty.tools.dotc.core.Types$NoType$ and dotty.tools.dotc.typer.Implicits$SearchFailureType are in unnamed module of loader sbt.internal.classpath.ClassLoaderCache$Key$CachedClassLoader @6abc0a67)
[error] Total time: 13 s, completed Nov 3, 2025, 9:44:47 AM
[IJ]

code compiles with scalac 3.3.5, 3.3.6

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions