当我将 Wrapper 定义为值类(扩展 AnyVal)时:
class Wrapper(val string: String) extends AnyVal
def wrapperHolder(w: Wrapper): {def wrapper: Wrapper} = new {
def wrapper: Wrapper = w
}
我对 wrapperHolder 有以下编译错误:
Error:(5, 22) Result type in structural refinement may not refer to a user-defined value class
def wrapper: Wrapper = w
- 为什么它不适用于价值类?