Skip to content

Match on Nothing doesn't -Ycheck #5073

Closed
@OlivierBlanvillain

Description

@OlivierBlanvillain
??? match {
  case Some(_) => ()
}
*** error while checking /home/olivier/workspace/dotty/tests/pos/annot-2.scala after phase splitter ***
exception occurred while compiling /home/olivier/workspace/dotty/tests/pos/annot-2.scala                                   Exception in thread "main" java.lang.AssertionError: assertion failed: symbols differ for x1.ne
was                 : method ne                                        
alternatives by type:  of types                                                               
qualifier type      : => Nothing(???)(x1)                                    
tree type           : ((x$0: Object): Boolean)(x1.ne) of class class dotty.tools.dotc.core.Types$CachedTermRef

scalac rejects that code in typer:

scala> ??? match {
     |   case Some(_) => ()
     | }
<console>:13: error: constructor cannot be instantiated to expected type;
 found   : Some[A]
 required: Nothing
         case Some(_) => ()
              ^

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions