Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor XsdNonLocalElement unapply #2

Open
bbarker opened this issue Jun 30, 2017 · 0 comments
Open

Refactor XsdNonLocalElement unapply #2

bbarker opened this issue Jun 30, 2017 · 0 comments

Comments

@bbarker
Copy link
Collaborator

bbarker commented Jun 30, 2017

I attempted to do this like so to remove some code duplication:

    @mutualrec
    final def lastMatch(last: Option[(String, Try[NodeWrap])], eArgs: EnumArgs): Option[(String, Try[NodeWrap])]  = last match {
      case Some((labelCarry: String, Success(node: NodeWrap)))
        if !isLocallyDefined(node.node) =>
        // Keep chasing the reference
        //TODO: above, need to check to see if we need worry about non-head elements
        unapply(NodeWrapCarry(node.node.child.head, eArgs, labelCarry))
      case _ => last
    }

    //    def unapply(arg: Node, eArgs: EnumArgs): Option[(String, Try[Node])] =
    //      unapply(NodeWrap(arg, eArgs))
    //
    //TODO: also looking up arg.fullName is not sufficient... need whole xpath?
    @mutualrec
    final def unapply(arg0: NodeWrapAbstract): Option[(String, Try[NodeWrap])] = {

      val (last, eArgs) = arg0 match {
        case argNW@NodeWrap(arg: Node, eArgs: EnumArgs) =>
          (unapplyMatcher(argNW, ""), eArgs)
        case NodeWrapCarry(arg: Node, eArgs: EnumArgs, label: String) =>
          (unapplyMatcher(NodeWrap(arg, eArgs), label), eArgs)
      }
      lastMatch(last, eArgs)
    }
  }

However, this results in "Unable to tail call optimize as this is either not effectively final or a non-constructor method". The issue appears to be that different signatures in the mutual methods are not supported, currently a scalac convention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant