This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 255486 - ErrorType element of for-loop variable
Summary: ErrorType element of for-loop variable
Status: RESOLVED WORKSFORME
Alias: None
Product: java
Classification: Unclassified
Component: Source (show other bugs)
Version: 8.1
Hardware: PC Linux
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-09-22 13:38 UTC by Martin Entlicher
Modified: 2016-01-07 14:47 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Test project (19.88 KB, application/x-zip-compressed)
2015-09-22 13:38 UTC, Martin Entlicher
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Entlicher 2015-09-22 13:38:31 UTC
Created attachment 156351 [details]
Test project

Issue #255429 revealed a problem in elements resolution.

Consider the attached project. At line 28 there is "child" variable being accessed. When I ask for it's element, it return Symbol$ClassSymbol, whose name is "child" and type is an instance of Type$ErrorType. This is clearly wrong.

To reproduce, when visitIdentifier(IdentifierTree arg0, ...) is called during the parsing, get an element this way:
  TreePath currentPath = getCurrentPath();
  TreePath identifierPath = TreePath.getPath(currentPath, arg0);
  Element elm = evaluationContext.getTrees().getElement(identifierPath);
The elm is wrongly Symbol$ClassSymbol and ((TypeElement) elm).asType() is Type$ErrorType.

When you add parenthesis around the for-loop body:
        for (Worker child: worker.getChildren()) {
            startYear(child, listener);
        }
it gets corrected:
elm is Symbol$VarSymbol and elm.getKind() is LOCAL_VARIABLE.
Comment 1 Svata Dedic 2016-01-07 14:47:43 UTC
I can't seem to reproduce it in the dev build