- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Closed
Milestone
Description
  type T[X] = X match {
    case String => Int
    case Int => String
  }
  class Box[X](x: X)
  def f[X <: String | Int](x: X): T[X] = Box(x) match {
    case x: Box[Int] => ""        // <-- error
    case x: Box[String] => 1
  }This gives:
10 |    case x: Box[Int] => ""
   |                        ^^
   |              Found:    String("")
   |              Required: Test.T[X]
   |              
   |              where:    X is a type in method f which is an alias of Int
If I swap the two cases in the match type the error is on the next line. This seems to indicate that the problem is in the no-overlap checks for match types. Maybe it needs to be strengthened for GADT aliases.
Generally:
- it would be good to play with more cases like this one
- it would be good to invest effort in better diagnostics when no-overlap check fails.
DmytroMitin
Metadata
Metadata
Assignees
Labels
No labels