Getting rid of Computable and Function in lazy values and memoized functions

This commit is contained in:
Andrey Breslav
2013-10-04 19:17:10 +04:00
committed by Alexander Udalov
parent 4d28dfada6
commit 7d1c46ed2c
27 changed files with 103 additions and 131 deletions
@@ -237,7 +237,7 @@ public class AnnotationDescriptorDeserializer implements AnnotationDeserializer
errorReporter.reportAnnotationLoadingError("Kotlin class for loading member annotations is not found: " + container, null);
}
List<AnnotationDescriptor> annotations = memberAnnotations.fun(kotlinClass).get(signature);
List<AnnotationDescriptor> annotations = memberAnnotations.invoke(kotlinClass).get(signature);
return annotations == null ? Collections.<AnnotationDescriptor>emptyList() : annotations;
}
@@ -105,7 +105,7 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet
@NotNull
@Override
public Set<JetType> getUpperBounds() {
return upperBounds.compute();
return upperBounds.invoke();
}
@NotNull
@@ -114,7 +114,7 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet
@NotNull
@Override
public JetType getUpperBoundsAsType() {
return upperBoundsAsType.compute();
return upperBoundsAsType.invoke();
}
@NotNull
@@ -144,7 +144,7 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet
@NotNull
@Override
public TypeConstructor getTypeConstructor() {
return typeConstructor.compute();
return typeConstructor.invoke();
}
@NotNull
@@ -192,7 +192,7 @@ public abstract class AbstractLazyTypeParameterDescriptor implements TypeParamet
@NotNull
@Override
public JetType getDefaultType() {
return defaultType.compute();
return defaultType.invoke();
}
@NotNull
@@ -30,6 +30,6 @@ public class LazyScopeAdapter extends AbstractScopeAdapter {
@NotNull
@Override
protected JetScope getWorkerScope() {
return scope.compute();
return scope.invoke();
}
}
@@ -143,7 +143,7 @@ class BuiltinsNamespaceDescriptorImpl extends AbstractNamespaceDescriptorImpl {
@NotNull
@Override
public Collection<Name> getClassNames(@NotNull FqName packageName) {
return packageName.equals(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) ? classNames.compute() : Collections.<Name>emptyList();
return packageName.equals(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME) ? classNames.invoke() : Collections.<Name>emptyList();
}
}
}
@@ -181,11 +181,6 @@ public class LockBasedStorageManager implements StorageManager {
@Override
public T invoke() {
return compute();
}
@Override
public T compute() {
Object _value = value;
if (!(value instanceof NotValue)) return WrappedValues.unescapeThrowable(_value);
@@ -245,8 +240,8 @@ public class LockBasedStorageManager implements StorageManager {
@Override
@NotNull
public T compute() {
T result = super.compute();
public T invoke() {
T result = super.invoke();
assert result != null : "compute() returned null";
return result;
}
@@ -263,14 +258,9 @@ public class LockBasedStorageManager implements StorageManager {
this.compute = compute;
}
@Override
public V invoke(K k) {
return fun(k);
}
@Override
@Nullable
public V fun(@NotNull K input) {
public V invoke(@NotNull K input) {
Object value = cache.get(input);
if (value != null) return WrappedValues.unescapeExceptionOrNull(value);
@@ -311,8 +301,8 @@ public class LockBasedStorageManager implements StorageManager {
@NotNull
@Override
public V fun(@NotNull K input) {
V result = super.fun(input);
public V invoke(@NotNull K input) {
V result = super.invoke(input);
assert result != null : "compute() returned null";
return result;
}
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.util.Function;
import jet.Function1;
import org.jetbrains.annotations.NotNull;
public interface MemoizedFunctionToNotNull<P, R> extends Function<P, R>, Function1<P, R> {
@Override
@NotNull
R fun(P p);
public interface MemoizedFunctionToNotNull<P, R> extends Function1<P, R> {
@Override
@NotNull
R invoke(P p);
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.util.Function;
import jet.Function1;
import org.jetbrains.annotations.Nullable;
public interface MemoizedFunctionToNullable<P, R> extends Function<P, R>, Function1<P, R> {
@Override
@Nullable
R fun(P p);
public interface MemoizedFunctionToNullable<P, R> extends Function1<P, R> {
@Override
@Nullable
R invoke(P p);
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.openapi.util.Computable;
import jet.Function0;
import org.jetbrains.annotations.NotNull;
public interface NotNullLazyValue<T> extends Computable<T>, Function0<T> {
@Override
@NotNull
T compute();
public interface NotNullLazyValue<T> extends Function0<T> {
@Override
@NotNull
T invoke();
@@ -16,15 +16,10 @@
package org.jetbrains.jet.storage;
import com.intellij.openapi.util.Computable;
import jet.Function0;
import org.jetbrains.annotations.Nullable;
public interface NullableLazyValue<T> extends Computable<T>, Function0<T> {
@Override
@Nullable
T compute();
public interface NullableLazyValue<T> extends Function0<T> {
@Override
@Nullable
T invoke();