Result type in structural refinement may not refer to a user-defined value class

徘徊边缘 提交于 2019-12-22 05:54:22

问题


When I define Wrapper as value class(extending AnyVal):

class Wrapper(val string: String) extends AnyVal

def wrapperHolder(w: Wrapper): {def wrapper: Wrapper} = new {
  def wrapper: Wrapper = w
}

I have following compile error for wrapperHolder:

Error:(5, 22) Result type in structural refinement may not refer to a user-defined value class
def wrapper: Wrapper = w
  • Why it doesn't work for value class?

来源:https://stackoverflow.com/questions/52678323/result-type-in-structural-refinement-may-not-refer-to-a-user-defined-value-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!