Skip to content

"match may not be exhaustive" from synthetic code #12602

Closed
@lrytz

Description

@lrytz
sealed class Foo[T]
object Foo extends Foo[Nothing]

gives

result of Test.scala after MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce, inlineVals, expandSAMs}:
package <empty> {
  @scala.annotation.internal.SourceFile("Test.scala") @
    scala.annotation.internal.Child
  [Foo.type]() sealed class Foo[T]() extends Object() {
    T
  }
  final lazy module val Foo: Foo$ = new Foo$()
  @scala.annotation.internal.SourceFile("Test.scala") final module class Foo$()
     extends
   Foo[Nothing](), scala.deriving.Mirror.Sum {
    private def writeReplace(): AnyRef =
      new scala.runtime.ModuleSerializationProxy(classOf[Foo.type])
    type MirroredMonoType = Foo[? <: AnyKind]
    def ordinal(x$0: Foo.MirroredMonoType): Int =
      x$0 match
        {
          case _:Foo.type => 0
        }
  }
}
result of Test.scala after MegaPhase{elimRepeated, protectedAccessors, extmethods, uncacheGivenAliases, byNameClosures, hoistSuperArgs, specializeApplyMethods, refchecks}:
  Unchanged since MegaPhase{firstTransform, checkReentrant, elimPackagePrefixes, cookComments, checkStatic, betaReduce, inlineVals, expandSAMs}
-- [E029] Pattern Match Exhaustivity Warning: Test.scala:1:28 ------------------
1 |sealed class Foo[T]; object Foo extends Foo[Nothing]
  |                            ^
  |                            match may not be exhaustive.
  |
  |                            It would fail on pattern case: _: Foo[_]

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions