Author Topic: SE 24.0.2 Java9+ Trouble with local 'var's  (Read 124 times)

Marcel

  • Senior Community Member
  • Posts: 240
  • Hero Points: 26
SE 24.0.2 Java9+ Trouble with local 'var's
« on: July 11, 2020, 09:36:15 pm »
SE has a hard time tracking var types.  In the following code sample, SE has no idea what class the "someSubs" variable in either of the 2 for-loops contains.

Code: [Select]
package com.acme.stuff;
import java.util.HashMap;
import java.util.Map;
public class Subs {
  private Map<String,Subs> sublist = new HashMap<>();
  public void doSomeThing() {
    for (var entry : sublist.entrySet()) {
      var someSubs = entry.getValue();
    }

    for (Map.Entry entry : sublist.entrySet()) {
      var someSubs = entry.getValue();
    }
  }
  public String getSecrets() {
    return "something";
  }
}

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2972
  • Hero Points: 440
Re: SE 24.0.2 Java9+ Trouble with local 'var's
« Reply #1 on: July 13, 2020, 10:01:07 pm »
This will be fixed in the next hot fix for 24.0.2.