-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't flag match type aliases as unreducible
If `M[_]` is a match type alias, it was rejected for being an unreducible application of wildcard types. It is now accepted. I believe that is sound - this is siply an unreducible match type. The situation is not the same as `F[_]` where `F` is an abstract type that can be refined in several ways in subclasses. Fixes #9999
- Loading branch information
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,6 +35,7 @@ i7872.scala | |
i11236.scala | ||
i11247.scala | ||
i11250 | ||
i9999.scala | ||
|
||
# Opaque type | ||
i5720.scala | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
case class A(); | ||
case class B(); | ||
|
||
type M2[X <: A|B] = X match { | ||
case A => A | ||
case B => B | ||
} | ||
|
||
def f2(x: A|B): M2[x.type] = x match { | ||
case _: A => A() | ||
case _: B => B() | ||
} | ||
|
||
type M1[X <: A|B] = X match { | ||
case A => A | ||
case B => (x: A|B) => M2[x.type] | ||
} | ||
|
||
def f1(x: A|B): M1[x.type] = x match { | ||
case _: A => A() | ||
case _: B => (x: A|B) => f2(x) | ||
} | ||
|
||
case class More(); case class Stop(); | ||
|
||
sealed abstract class DSL | ||
case class Fun[F <: More|Stop => DSL](cont: F) extends DSL | ||
case class Nop() extends DSL | ||
|
||
type Match2[X <: More|Stop] <: DSL = X match { | ||
case More => Fun[(y: More|Stop) => Match1[y.type]] | ||
case Stop => Nop | ||
} | ||
type Match1[X] <: DSL = X match { | ||
case More => Nop | ||
case Stop => Nop | ||
} | ||
|
||
def fun2(x: More|Stop): Match2[x.type] = x match { | ||
case _: More => Fun(fun1) // error | ||
case _: Stop => Nop() | ||
} | ||
|
||
def fun1(y: More|Stop): Match1[y.type] = y match { | ||
case _: More => Nop() | ||
case _: Stop => Nop() | ||
} |