Re: [Jastadd] [bug report] overloaded methods in an inner class of a generic class

From: Jesper qvist <jesper.oqvist_at_cs.lth.se>
Date: Fri, 04 May 2012 17:25:59 +0200

Progress update on this bug: confirmed but not fixed. The suggested fix
caused other, possibly more complex errors. Will continue work on this
when there is time. I'll try to fix the simpler bugs meanwhile.

/Jesper

On 03/18/2012 09:38 AM, Na, Hyunik wrote:
>
> Hello JastAddJ deverlopers,
>
> For the following example,
>
> -=-=-=
>
> public class Test {
>
> public static void main( String [] args ) {
>
> C<F> c = new C<F>();
>
> c.new D( new F() );
>
> }
>
> }
>
> class C<X> {
>
> class D {
>
> D( X e ) { }
>
> D( F e ) { }
>
> }
>
> }
>
> class F { }
>
> -=-=-=
>
> javac produces the following error message.
>
> -=-=-=
>
> [hina_at_hyunikLinux test]$ javac Test.java
>
> Test.java:8: reference to D is ambiguous, both method D(X) in C<F>.D
> and method D(F) in C<F>.D match
>
> c.new D( new F() );
>
> ^
>
> 1 error
>
> -=-=-=
>
> But, JastAddJ (rev. 9233) allows this program.
>
> Though I have not examined the Java language specification about this
> issue, javac?s result seems more reasonable.
>
> To get a similar result as javac, the following simple modification of
> ConstructorDecl.moreSpecificThan(ConstructorDecl) may be adequate
>
> -=-=-=
>
> syn lazy boolean ConstructorDecl.moreSpecificThan(ConstructorDecl m) {
>
> boolean diffFound = false; // *
>
> for(int i = 0; i < getNumParameter(); i++) {
>
> if(!getParameter(i).type().instanceOf(m.getParameter(i).type()))
>
> return false;
>
>
> if(!getParameter(i).type().identityConversionTo(m.getParameter(i).type()))
> // *
>
> diffFound = true; // *
>
> }
>
> if ( !diffFound ) return false; // *
>
> return true;
>
> }
>
> -=-=-=
>
> where added four lines are marked by ?// *?.
>
> Current ConstructorDecl.moreSpecificThan() returns true not only for a
> ?more specific? case, but also for a ?equally specific? case.
>
> The above modification is to return false for equally specific cases.
>
> Similar things should be done to MothodDecl.moreSpecificThan() and to
> the refined moreSpecificThan()?s for variable arity
>
> constructors and methods in Java1.5Frontend/MethodSignature.jrag.
>
> I hope this helps.
>
> Cheers,
>
> - Hyunik
>
>
> _______________________________________________
> JastAdd mailing list
> JastAdd_at_cs.lth.se
> https://mail1.cs.lth.se/cgi-bin/mailman/listinfo/jastadd
Received on Fri May 04 2012 - 17:25:20 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 16 2014 - 17:19:06 CEST