【发布时间】:2013-04-25 01:27:42
【问题描述】:
我有这个 pattern match 匹配 only 字节值但是当我添加 @switch 它说:
无法发出切换到@switch 注释匹配
我在这里错过了什么?
仅供参考,我已经尝试过但没有奏效:
- 将此常量移动到 Java 接口并使用
public static final byte字段(我也尝试将它们设为int而不是byte) - 在 Scala
Message伴随对象中将字段标记为final val - 在伴随对象中将字段标记为
@inline
我肯定迷路了。
【问题讨论】:
-
我是impossible:
a non-literal may prevent switch generation: this would not compile。 -
这篇文章包含一个死链接,使问题不完整,如果原始海报还在,你能解决这个问题吗
-
现在它包含了正确的链接。
标签: scala optimization pattern-matching switch-statement constants