[antlr-interest] anybody get bitten by ANTLR's AST interface requirement

Sohail Somani sohail at taggedtype.net
Mon Jan 23 19:54:28 PST 2006


On Mon, 2006-01-23 at 17:48 +0530, Krishanu Debnath wrote:
> Sohail Somani wrote:
> > On Fri, 2006-01-20 at 09:49 +0100, Martin Probst wrote:
> >> A 1.5 feature I consider quite important never gets mentioned btw:
> >> overriding methods can now declare a subclass as the return type, e.g.
> >> if you have "class B extends A {}" and some method "A doFoo()" you can
> >> override it to "B doFoo()". User correctly this can significantly
> >> enhance APIs and type safety.
> > 
> > I think these are called covariant returns in the C++ world. Are they
> > the same idea?
> > 
> 
> No. This is not allowed in C++. Functions declarations that differ only in the
> return type cannot be overloaded.

Perhaps I should've looked at this earlier, but the site here seems to
say that you can't have two doFoo()'s in the same class that return
different types:

http://java.sun.com/developer/JDCTechTips/2004/tt1201.html




More information about the antlr-interest mailing list