Skip to content

Match type pattern with compiletime.ops isn't simplified #20166

Closed
@EugeneFlesselle

Description

@EugeneFlesselle

Compiler version

3.5.0-RC1

Minimized code

import scala.compiletime.ops.int.+

type M[I <: Int] = 0 match
  case 1 + 1 => "a"
  case I + 1 => "b"
  case _ => "c"

val _: M[1] = "c"

Output

-- [E007] Type Mismatch Error: tests/playground/example.scala:8:14 -------------
8 |val _: M[1] = "c"
  |              ^^^
  |            Found:    ("c" : String)
  |            Required: M[(1 : Int)]
  |
  |            Note: a match type could not be fully reduced:
  |
  |              trying to reduce  M[(1 : Int)]
  |              failed since selector (0 : Int)
  |              does not match  case (1 : Int) + (1 : Int) => ("b" : String)
  |              and cannot be shown to be disjoint from it either.
  |              Therefore, reduction cannot advance to the remaining case
  |
  |                case _ => ("c" : String)
  |-----------------------------------------------------------------------------
  | Explanation (enabled by `-explain`)
  |- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  |
  | Tree: "c"
  | I tried to show that
  |   ("c" : String)
  | conforms to
  |   M[(1 : Int)]
  | but none of the attempts shown below succeeded:
  |
  |   ==> ("c" : String)  <:  M[(1 : Int)]
  |     ==> ("c" : String)  <:  (0 : Int) match {   case (2 : Int) => ("a" : String)   case (1 : Int) + (1 : Int) => ("b" : String)   case Any => ("c" : String) } <: ("a" : String) | ("b" : String) | ("c" : String)
  |       ==> String  <:  (0 : Int) match {   case (2 : Int) => ("a" : String)   case (1 : Int) + (1 : Int) => ("b" : String)   case Any => ("c" : String) } <: ("a" : String) | ("b" : String) | ("c" : String)  = false
  |
  | The tests were made under the empty constraint
   -----------------------------------------------------------------------------

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions