Skip to main content



      Home
Home » Modeling » TMF (Xtext) » StackOverflowError when calling super in override dispatch method
StackOverflowError when calling super in override dispatch method [message #1782864] Fri, 02 March 2018 11:26 Go to next message
Eclipse UserFriend
Hi,

I have two classes. Class B extends class A like this:

class A {
  def dispatch String doA(Object a) {}
  def dispatch String doA(String a) {}
}

class B extends A {
  override dispatch String doA(String a) {
    if (a.isEmpty)
      "empty"
    else
      super.doA(a)
  }
}


When I call new B().doA("123") I get an StackOverflowError. I just want to extend the behavior of doA in B and delegate the default to the super class. Any idea how to solve this?
Re: StackOverflowError when calling super in override dispatch method [message #1782866 is a reply to message #1782864] Fri, 02 March 2018 11:34 Go to previous messageGo to next message
Eclipse UserFriend
you can override a single dispatch case like

class B extends A {
  override dispatch String doA(String a) {
    if (a.isEmpty)
      "empty"
    else
      super._doA(a)
  }
}
Re: StackOverflowError when calling super in override dispatch method [message #1783339 is a reply to message #1782866] Mon, 12 March 2018 04:40 Go to previous messageGo to next message
Eclipse UserFriend
This solved my problem. Thank you.

One question. Calling super.doA(a) in a override dispatch method is always an error?
Re: StackOverflowError when calling super in override dispatch method [message #1783340 is a reply to message #1783339] Mon, 12 March 2018 04:50 Go to previous message
Eclipse UserFriend
calling super in general not, calling on the same parameter likely
Previous Topic:LSP: resolving types
Next Topic:Xtext using Xbase
Goto Forum:
  


Current Time: Wed Jul 30 19:18:21 EDT 2025

Powered by FUDForum. Page generated in 0.06559 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top