Bug 360644 - Scope.isDefinedInSameUnit(ReferenceBinding) fails for a ParameterizedTypeBinding
Summary: Scope.isDefinedInSameUnit(ReferenceBinding) fails for a ParameterizedTypeBinding
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Ayushman Jain CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-12 06:20 EDT by Ayushman Jain CLA
Modified: 2011-10-24 04:14 EDT (History)
1 user (show)

See Also:


Attachments
proposed fix (1.40 KB, patch)
2011-10-12 08:56 EDT, Ayushman Jain CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.