minor: anonymous ThreadLocal class -> ThreadLocal.withInitial

minor benefit is avoiding a reference cycle from anonymous class to
TypeEvalContext as anonymous inner classes always hold a reference to
the containing class
This commit is contained in:
fitermay
2018-02-28 21:36:46 -05:00
parent f2f54441b7
commit 44d758b1db
@@ -47,18 +47,8 @@ public class TypeEvalContext {
private final Map<PyTypedElement, PyType> myEvaluated = new HashMap<>();
private final Map<PyCallable, PyType> myEvaluatedReturn = new HashMap<>();
private final ThreadLocal<Set<PyTypedElement>> myEvaluating = new ThreadLocal<Set<PyTypedElement>>() {
@Override
protected Set<PyTypedElement> initialValue() {
return new HashSet<>();
}
};
private final ThreadLocal<Set<PyCallable>> myEvaluatingReturn = new ThreadLocal<Set<PyCallable>>() {
@Override
protected Set<PyCallable> initialValue() {
return new HashSet<>();
}
};
private final ThreadLocal<Set<PyTypedElement>> myEvaluating = ThreadLocal.withInitial(HashSet::new);
private final ThreadLocal<Set<PyCallable>> myEvaluatingReturn = ThreadLocal.withInitial(HashSet::new);
private TypeEvalContext(boolean allowDataFlow, boolean allowStubToAST, boolean allowCallContext, @Nullable PsiFile origin) {
myConstraints = new TypeEvalConstraints(allowDataFlow, allowStubToAST, allowCallContext, origin);
@@ -254,7 +244,7 @@ public class TypeEvalContext {
}
/**
* @return context constraints (see {@link com.jetbrains.python.psi.types.TypeEvalConstraints}
* @return context constraints (see {@link TypeEvalConstraints}
*/
@NotNull
TypeEvalConstraints getConstraints() {