Project
IntelliJ IDEA
Priority
Critical
Type
Bug
Fix versions
No Fix versions
State
Fixed
Assignee
Eugene Vigdorchik
Subsystem
Editor. Error Highlighting
Affected versions
No Affected versions
Fixed in build
108.65  
  • Created by   Maxim Shafirov
    5 years ago (07 Jan 2007 18:36)
  • Updated by   root
    2 years ago (17 Jan 2010 20:39)
  • Jira: IDEADEV-13011
    (history, comments)
 
IDEA-36183 Bad code is green
0
Issue is visible to: All Users
  The issue is visible to the selected user group only
public class LimitedPool<T> {
  private int capacity;
  private final ObjectFactory<T> factory;
  private Object[] storage;
  private int index = 0;

  public LimitedPool(final int capacity, ObjectFactory<T> factory) {
    this.capacity = capacity;
    this.factory = factory;
    storage = new Object[capacity];
  }

  interface ObjectFactory<T> {
    T create();
    void cleanup(T t);
  }

  public T alloc() {
    if (index >= capacity) return factory.create();

    if (storage[index] == null) {
      storage[index] = factory.create();
    }

    return storage;   // Compile error here
  }

}


Issue was resolved
Comments (0)
 
History
 
Linked Issues (?)
 
Issue has no comments