问题描述
给定
type Bool
type True <: Bool
type False <: Bool
和
type Neg [B <: Bool] <: Bool =
B match
case True => False
case False => True
编译(这里没有惊喜):
summon [Neg [True] =:= False]
但令人惊讶的是,这并没有:
summon [Neg [False] =:= True]
这似乎取决于类型匹配中的大小写顺序 - 如果我更改 Neg
中的分支顺序,Neg [False]
会起作用,但 Neg [True]
不会?!>
Scala 3.0.0-RC3
编辑:
这按预期工作(Neg
不变):
trait Bool
class True extends Bool
class False extends Bool
这也是:
trait Bool
object True extends Bool
object False extends Bool
type True = True.type
type False = False.type
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)