Bug 107898 - [generics] Type mismatch when returning T (but stranger)
Summary: [generics] Type mismatch when returning T (but stranger)
Status: RESOLVED FIXED
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: DEVELOPMENT   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Adrian Colyer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-08-24 13:11 EDT by Samuel Gélineau CLA
Modified: 2005-08-25 13:18 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Samuel Gélineau CLA 2005-08-24 13:11:08 EDT
regression:
the following test case compiles using
AspectJ Compiler DEVELOPMENT built on Wednesday Aug 17, 2005 at 12:52:19 GMT
but causes a compile error using
AspectJ Compiler DEVELOPMENT built on Wednesday Aug 24, 2005 at 09:22:19 GMT

class Bug_Provider {
  public void enable_bug(Object argument) {}
}

class Null_Provider<T> extends Bug_Provider {
  public T get_typed_null() {
    return null;
  }
}

public class Bug {
  public static void main(String[] args) {
    Null_Provider<Integer> null_provider = new Null_Provider<Integer>() {};
    null_provider.enable_bug(null);
    Integer i = null_provider.get_typed_null(); // type mismatch
  }
}


note how a call to enable_bug(null) is required to exhibit the bug.
this call is sensitive to the compile-time value of its argument:

enable_bug(null)           bug enabled
enable_bug(new Object())   bug disabled
enable_bug(new String())   bug enabled
Object o = null;
enable_bug(o);             bug disabled
String s = null;
enable_bug(s);             bug enabled

if the definition of enable_bug is moved to Null_Provider, or if Null_Provider
overrides it, then the bug is disabled.

if null_provider is not an annonymous class, then enable_bug doesn't enable the
bug. however, this call does _not_ have to be made on the same target. in fact,
it can be made from a completely different method, class, or file; it will
always enable the bug as long as the compiler sees the statement before
get_typed_null().


well, this is the strangest aspectj bug i've reported yet!
Comment 1 Adrian Colyer CLA 2005-08-24 15:41:35 EDT
we've been doing some work on anonymous types in the last two days, but I can
confirm this bug is *not* related to the anonymous type registration changes we
made for the Asm Builder bug.

between the build dates that you mention, we upgraded from the eclipse 3.1 m6
jdt compiler level to eclipse 3.1 final level - given the nature of the report,
I half wonder if this is a bug that JDT themselves have introduced.... I'm going
to check it out in a plain java project...
Comment 2 Adrian Colyer CLA 2005-08-24 15:45:39 EDT
nice try, but it's *not* a JDT bug, Eclipse 3.1 is quite happy with this
program, so it's something that we've introduced...
Comment 3 Adrian Colyer CLA 2005-08-24 17:18:49 EDT
found it! A bug introduced when sorting out generics and itds, whereby we failed
to correctly parameterize a method binding found on a parameterized type binding.

this test case now passes, just running the full suite to make sure there are no
side effects, but that is extremely unlikely for such a localised fix.
Comment 4 Adrian Colyer CLA 2005-08-25 03:46:39 EDT
fixed in latest published build. Thanks for the clear bug report, it must have
taken a while to boil this one down to a simple reproduceable test case!
Comment 5 Samuel Gélineau CLA 2005-08-25 13:18:09 EDT
actually, there seems to be more to this bug. I have created a different bug
report (Bug #108014), because the specific problem described here is indeed
resolved.