Skip to content

-Yexplicit-nulls breaks anonymous sealed class implementations #23936

@WojciechMazur

Description

@WojciechMazur

Found when reproducing #23935 based on zio/zio codebase

Similar to #23933

Compiler version

Last good release: 3.8.0-RC1-bin-20250822-658c8bd-NIGHTLY
First bad release: 3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY

Minimized code

//> using options -Yexplicit-nulls

sealed abstract class IsSubtypeOfOutput[-A, +B] extends (A => B)
object IsSubtypeOfOutput:
  private val instance: IsSubtypeOfOutput[Any, Any] = new IsSubtypeOfOutput[Any, Any] { def apply(a: Any): Any = a }

Output

   while compiling: /Users/wmazur/projects/scala/community-build3/test.scala
        during phase: posttyper
                mode: Mode(ImplicitsEnabled,SafeNulls)
     library version: version (unknown)
    compiler version: version 3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY-git-712d5bc
            settings: -Yexplicit-nulls true -classpath /Users/wmazur/Library/Caches/Coursier/v1/https/repo.scala-lang.org/artifactory/maven-nightlies/org/scala-lang/scala3-library_3/3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY/scala3-library_3-3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY.jar:/Users/wmazur/Library/Caches/Coursier/v1/https/repo.scala-lang.org/artifactory/maven-nightlies/org/scala-lang/scala-librException in thread "main" ary/3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY/scala-library-3.8.0-RC1-bin-20250823-712d5bc-NIGHTLY.jar -d /Users/wmazur/projects/scala/community-build3/.scala-build/community-build3_073d723edf-9d23cdd7be/classes/main -sourceroot /Users/wmazur/projects/scala/community-build3

scala.MatchError: AppliedType(TypeRef(ThisType(TypeRef(NoPrefix,module class internal)),class Child),List(FlexibleType(OrType(TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class IsSubtypeOfOutput),TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Null)),TypeRef(ThisType(TypeRef(NoPrefix,module class <empty>)),class IsSubtypeOfOutput)))) (of class dotty.tools.dotc.core.Types$CachedAppliedType)
        at dotty.tools.dotc.core.Annotations$Annotation$Child$.unapply(Annotations.scala:244)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation$$anon$3.applyOrElse(SymDenotations.scala:1765)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation$$anon$3.applyOrElse(SymDenotations.scala:1765)
        at scala.collection.immutable.List.collect(List.scala:271)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.children(SymDenotations.scala:1765)
        at dotty.tools.dotc.core.SymUtils.whyNotGenericSum(SymUtils.scala:198)
        at dotty.tools.dotc.core.SymUtils.isGenericSum(SymUtils.scala:237)
        at dotty.tools.dotc.transform.SyntheticMembers.addMirrorSupport(SyntheticMembers.scala:703)
        at dotty.tools.dotc.transform.SyntheticMembers.addSyntheticMembers(SyntheticMembers.scala:726)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform$$anonfun$5(PostTyper.scala:473)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.withNoCheckNews(PostTyper.scala:151)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:474)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1621)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:42)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:536)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.loop$2(tpd.scala:1304)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1304)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transformStats(PostTyper.scala:609)
        at dotty.tools.dotc.ast.tpd$TreeMapWithPreciseStatContexts.transformStats(tpd.scala:1306)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1632)
        at dotty.tools.dotc.transform.MacroTransform$Transformer.transform(MacroTransform.scala:42)
        at dotty.tools.dotc.transform.PostTyper$PostTyperTransformer.transform(PostTyper.scala:599)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:20)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:383)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:337)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:376)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:380)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1327)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:373)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$2(Run.scala:420)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1$$anonfun$adapted$1(Run.scala:420)
        at scala.Function0.apply$mcV$sp(Function0.scala:45)
        at dotty.tools.dotc.Run.showProgress(Run.scala:482)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:420)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$adapted$1(Run.scala:432)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:69)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:432)
        at dotty.tools.dotc.Run.compileSources(Run.scala:319)
        at dotty.tools.dotc.Run.compile(Run.scala:304)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:37)
        at dotty.tools.dotc.Driver.process(Driver.scala:201)
        at dotty.tools.dotc.Driver.process(Driver.scala:169)
        at dotty.tools.dotc.Driver.process(Driver.scala:181)
        at dotty.tools.dotc.Driver.main(Driver.scala:211)
        at dotty.tools.dotc.Main.main(Main.scala)
Compilation failed

Expectation

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions