Bug 329593 - [1.4/1.5] [compiler] incorrect error about incompatible operand
Summary: [1.4/1.5] [compiler] incorrect error about incompatible operand
Status: VERIFIED DUPLICATE of bug 329588
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.7   Edit
Hardware: PC Mac OS X - Carbon (unsup.)
: P3 normal (vote)
Target Milestone: 3.7 M4   Edit
Assignee: Srikanth Sankaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 329589 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-11-05 16:48 EDT by Thomas Watson CLA
Modified: 2010-12-07 12:15 EST (History)
1 user (show)

See Also:


Attachments
test project (3.29 KB, application/octet-stream)
2010-11-05 16:48 EDT, Thomas Watson CLA
no flags Details
Regression test (2.08 KB, patch)
2010-11-06 13:25 EDT, Srikanth Sankaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Watson CLA 2010-11-05 16:48:51 EDT
Created attachment 182531 [details]
test project

This setup may be considered bogus.  Basically we have a project compiling with the jsr14 flag but compiling against the J2SE 1.4 class library.  To reproduce you must have a 1.4 VM configured into your workspace and import the attached project.

It complains about code like this:

Class type == null;
if (type == byte.class) <== fails here
  return;
Comment 1 Olivier Thomann CLA 2010-11-05 16:50:55 EDT
I wonder if we should not check if java.lang.Class is generic before creating a parameterized type binding for "byte.class".
Comment 2 Srikanth Sankaran CLA 2010-11-06 01:27:40 EDT
(In reply to comment #0)
> Created an attachment (id=182531) [details]
> test project
> 
> This setup may be considered bogus.  Basically we have a project compiling with
> the jsr14 flag but compiling against the J2SE 1.4 class library.  To reproduce
> you must have a 1.4 VM configured into your workspace and import the attached
> project.
> 
> It complains about code like this:
> 
> Class type == null;
> if (type == byte.class) <== fails here
>   return;

[Srikanth slapping himself on his forehead]

I should have anticipated this problem. This is really the
other side of the coin so to speak as is obvious from
https://bugs.eclipse.org/bugs/show_bug.cgi?id=328827#c3

That bug was fixed the method isEquivalentTo in the TypeBinding
hierarchy. We should also fix the method isProvablyDistinct
in the TypeBinding hierarchy.

Patch will follow shortly.
Comment 3 Srikanth Sankaran CLA 2010-11-06 08:52:57 EDT
(In reply to comment #2)

> I should have anticipated this problem. This is really the
> other side of the coin so to speak as is obvious from
> https://bugs.eclipse.org/bugs/show_bug.cgi?id=328827#c3

https://bugs.eclipse.org/bugs/show_bug.cgi?id=323633#c14
does anticipate these issues. FWIW.
Comment 4 Srikanth Sankaran CLA 2010-11-06 13:25:13 EDT
(In reply to comment #0)
> Created an attachment (id=182531) [details]
> test project
> 
> This setup may be considered bogus.  Basically we have a project compiling with
> the jsr14 flag but compiling against the J2SE 1.4 class library. 

The oddity with the set up is just a red herring. The problem is the same
as in bug 329588. In establishing type equivalence, we need to be prepared
to see a type in one of three forms : as a parameterized form, a raw form
or a "plain" (1.4) form.

I'll add a regression test and close this as a duplicate of bug 329588.

(In reply to comment #1)
> I wonder if we should not check if java.lang.Class is generic before creating a
> parameterized type binding for "byte.class".

This does fix the current problem, but the more general fix is already committed
via the fix to bug 329588
Comment 5 Srikanth Sankaran CLA 2010-11-06 13:25:59 EDT
Created attachment 182557 [details]
Regression test

junit for test case corresponding to comment# 0
Comment 6 Srikanth Sankaran CLA 2010-11-06 13:28:22 EDT
TypeBinding Class is now not provably distinct from
Class<java.lang.Byte>

*** This bug has been marked as a duplicate of bug 329588 ***
Comment 7 Srikanth Sankaran CLA 2010-11-06 13:37:22 EDT
Released regression test in HEAD for 3.7 M4
Comment 8 Srikanth Sankaran CLA 2010-11-06 22:32:26 EDT
*** Bug 329589 has been marked as a duplicate of this bug. ***
Comment 9 Olivier Thomann CLA 2010-12-07 12:15:29 EST
Verified using I20101207-0250 (4.1 I-build)