Bug 88506

Summary: Scope incorrect for annotation values
Product: [Eclipse Project] JDT Reporter: Tim Hanson <thanson>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: RESOLVED DUPLICATE QA Contact:
Severity: normal    
Priority: P3    
Version: 3.1   
Target Milestone: 3.1 M6   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Tim Hanson CLA 2005-03-18 14:37:19 EST
The following example should not compile:

@interface ann
{
    Class foo();
}

@ann(foo=Inner.class)
class Outer
{
    public static class Inner
    {
    }
}

The reference to Inner.class in the annotation member value is not in scope.
According to the JLS section 6.3:

The scope of a declaration of a member m declared in or inherited by a
class type C is the entire body of C, including any nested type
declarations.

This implies that Inner is only in scope within the body of Outer. It should
only work if the type name is qualified as Outer.Inner.
Comment 1 Olivier Thomann CLA 2005-03-18 16:28:09 EST
Using latest I get:
----------
1. ERROR in C:\tests_sources\X.java
 (at line 6)
	@ann(foo=Inner.class)
	         ^^^^^
Inner cannot be resolved to a type
----------
1 problem (1 error)
Comment 2 Tim Hanson CLA 2005-03-18 16:38:04 EST
I have confirmed this using the head revision.
Comment 3 Philipe Mulet CLA 2005-03-18 19:43:02 EST
dup
Comment 4 Philipe Mulet CLA 2005-03-18 19:43:32 EST
closed as dup

*** This bug has been marked as a duplicate of 86291 ***
Comment 5 Philipe Mulet CLA 2005-03-19 04:08:23 EST
Note that method annotations are still seeing method scope.