Bug 88506 - Scope incorrect for annotation values
Summary: Scope incorrect for annotation values
Status: RESOLVED DUPLICATE of bug 86291
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M6   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-18 14:37 EST by Tim Hanson CLA
Modified: 2005-03-19 04:08 EST (History)
0 users

See Also:


Attachments

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