bug-kawa
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-kawa] [bug #16515] Overriding a method with incompatible return typ


From: Dean Ferreyra
Subject: [Bug-kawa] [bug #16515] Overriding a method with incompatible return types should result in compile-time error
Date: Wed, 3 May 2006 15:01:03 -0700
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.3) Gecko/20060426 Firefox/1.5.0.3

URL:
  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=16515>

                 Summary: Overriding a method with incompatible return types
should result in compile-time error
                 Project: Kawa
            Submitted by: dferreyra
            Submitted on: Wednesday 05/03/06 at 15:01
                Category: Type declaration and inference
                Severity: 3 - Normal
              Item Group: None
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open

    _______________________________________________________

Details:

Here's a simple example from Chris Dean:

--------------------------------------------------
This Java class will not compile because the return value for getTime() is of
the wrong type:

  public class MyJavaClass extends java.util.Date {
        public String getTime() {
            return( "a string" );
        }
    }

  MyJavaClass.java:2: getTime() in MyJavaClass cannot override getTime() in
java.util.Date; attempting to use incompatible return type
    found : java.lang.String
    required: long
        public String getTime() {
                    ^
    1 error

However, this Kawa code will compile and produce the wrong class:

  (define-simple-class <MySchemeClass> (<java.util.Date>)
    ((getTime)
     "a string"))
--------------------------------------------------

Attached is a more complicated example based on a problem encountered by our
developers.  The part that's at first surprising is that which method gets
called depends on how the function being returned has been defined (see
base-lambda vs. base-fn).

I think it boils down to the fact that in the <A>/<B> example, the signatures
of A.m0 and B.m0 vary in return type.  The results mentioned in the comments
only apply to compiled code.

Maybe there's another problem being exposed by this example, but I think if
the compiler issued an error when it encounters an override with incompatible
return types, it would help narrow down these problems much more quickly.

This isn't a show-stopper.  It crops up every once in a while and is
difficult to debug, and it would be nice if some kind of fix worked its way
into Kawa.






    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Wednesday 05/03/06 at 15:01  Name: override.scm  Size: 1.6KB   By:
dferreyra
The more complicated example
<http://savannah.gnu.org/bugs/download.php?file_id=9886>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?func=detailitem&item_id=16515>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]