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 270238 - Hint "The assigned value is never used" shown while variable is used in switch statement
Summary: Hint "The assigned value is never used" shown while variable is used in switc...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.1
Hardware: PC Windows 10 x64
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-03-29 07:05 UTC by MCEmperor
Modified: 2017-03-29 07:05 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description MCEmperor 2017-03-29 07:05:15 UTC
Hint "The assigned value is never used" is shown when the value is overwritten by a statement in the switch statement.

    boolean someCondition = true;
    int someInt = 4;
		
    String value = "initialValue";
    if (someCondition) {
        switch (someInt) {
            case 4:
                value = "anotherValue";
                break;
            default:
                throw new IllegalArgumentException();
        }
    }
    System.out.println(value);

The hint occurs at the line

    value = "anotherValue";

but if you run this code, the text "anotherValue" is printed to stdout.