Bug 360644

Summary: Scope.isDefinedInSameUnit(ReferenceBinding) fails for a ParameterizedTypeBinding
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: CoreAssignee: Ayushman Jain <amj87.iitr>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: srikanth_sankaran
Version: 3.8   
Target Milestone: 3.8 M3   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
proposed fix none

Description Ayushman Jain CLA 2011-10-12 06:20:35 EDT
HEAD

When one tries to query a ParameterizedTypeBinding using the method Scope.isDefinedInSameUnit(ReferenceBinding) , the return value is false even if the ParameterizedBinding was indeed defined in the same unit. This is because the comparison in the method occurs at line 3046 between the top level types obtained from the compilation unit and the queried type. Since the top level types are always a SourceTypeBinding, the comparison with a parameterized type binding will fail even if it is actually the same type. Hence, for Parameterized types we should compare as follows:

if (enclosingType instanceof ParameterizedTypeBinding)
if (topLevelTypes[i] == ((ParameterizedTypeBinding)enclosingType).type)
  return true;
Comment 1 Ayushman Jain CLA 2011-10-12 06:26:42 EDT
(In reply to comment #0)
> if (enclosingType instanceof ParameterizedTypeBinding)
> if (topLevelTypes[i] == ((ParameterizedTypeBinding)enclosingType).type)
>   return true;

Actually, using enclosingType.original() should suffice.
Comment 2 Ayushman Jain CLA 2011-10-12 08:56:41 EDT
Created attachment 205028 [details]
proposed fix
Comment 3 Ayushman Jain CLA 2011-10-12 08:57:08 EDT
Released in HEAD for 3.8M3 via commit 21098f5e40f4c2eaaad3e643b94e7cf0a54113c9.
Comment 4 Srikanth Sankaran CLA 2011-10-24 04:14:49 EDT
Verified for 3.8 M3 via code inspection.