diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java index 4245de36633..93b8941a476 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -23,6 +23,7 @@ import com.google.common.collect.Lists; import com.intellij.psi.PsiElement; import jet.Function0; import jet.Function1; +import jet.Unit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; @@ -401,11 +402,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc return Collections.emptyList(); } }, - new Function1, Void>() { + new Function1, Unit>() { @Override - public Void invoke(@NotNull Collection supertypes) { + public Unit invoke(@NotNull Collection supertypes) { findAndDisconnectLoopsInTypeHierarchy(supertypes); - return null; + return Unit.VALUE; } }); diff --git a/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java b/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java index ad06f4be272..3debea3cb93 100644 --- a/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java +++ b/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java @@ -2,6 +2,7 @@ package org.jetbrains.jet.storage; import jet.Function0; import jet.Function1; +import jet.Unit; import junit.framework.TestCase; import org.jetbrains.jet.util.ReenteringLazyValueComputationException; @@ -238,10 +239,10 @@ public class StorageManagerTest extends TestCase { } }, null, - new Function1() { + new Function1() { @Override - public Void invoke(String s) { - return null; + public Unit invoke(String s) { + return Unit.VALUE; } } ); @@ -272,12 +273,12 @@ public class StorageManagerTest extends TestCase { return "tolerant"; } }, - new Function1() { + new Function1() { @Override - public Void invoke(String s) { + public Unit invoke(String s) { counter.inc(); assertEquals("tolerant", s); - return null; + return Unit.VALUE; } } ); @@ -301,12 +302,12 @@ public class StorageManagerTest extends TestCase { } }, null, - new Function1, Void>() { + new Function1, Unit>() { @Override - public Void invoke(Collection strings) { + public Unit invoke(Collection strings) { counter.inc(); strings.add("postComputed"); - return null; + return Unit.VALUE; } } ); @@ -327,12 +328,12 @@ public class StorageManagerTest extends TestCase { return strings; } }, - new Function1, Void>() { + new Function1, Unit>() { @Override - public Void invoke(Collection strings) { + public Unit invoke(Collection strings) { counter.inc(); strings.add("postComputed"); - return null; + return Unit.VALUE; } } ); @@ -361,11 +362,11 @@ public class StorageManagerTest extends TestCase { return "second"; } }, - new Function1() { + new Function1() { @Override - public Void invoke(String s) { + public Unit invoke(String s) { fail("Recursion-tolerating value should not be post computed"); - return null; + return Unit.VALUE; } } ); diff --git a/core/util.runtime/src/org/jetbrains/jet/storage/LockBasedStorageManager.java b/core/util.runtime/src/org/jetbrains/jet/storage/LockBasedStorageManager.java index 171f6a53ea6..0fa35abb0ea 100644 --- a/core/util.runtime/src/org/jetbrains/jet/storage/LockBasedStorageManager.java +++ b/core/util.runtime/src/org/jetbrains/jet/storage/LockBasedStorageManager.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.storage; import jet.Function0; import jet.Function1; +import jet.Unit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.utils.ExceptionUtils; @@ -99,7 +100,7 @@ public class LockBasedStorageManager implements StorageManager { public NotNullLazyValue createLazyValueWithPostCompute( @NotNull Function0 computable, final Function1 onRecursiveCall, - @NotNull final Function1 postCompute + @NotNull final Function1 postCompute ) { return new LockBasedNotNullLazyValue(lock, computable) { @Nullable @@ -138,7 +139,7 @@ public class LockBasedStorageManager implements StorageManager { @NotNull @Override public NullableLazyValue createNullableLazyValueWithPostCompute( - @NotNull Function0 computable, @NotNull final Function1 postCompute + @NotNull Function0 computable, @NotNull final Function1 postCompute ) { return new LockBasedLazyValue(lock, computable) { @Override diff --git a/core/util.runtime/src/org/jetbrains/jet/storage/StorageManager.java b/core/util.runtime/src/org/jetbrains/jet/storage/StorageManager.java index 160f01da5c6..4c37eb9e663 100644 --- a/core/util.runtime/src/org/jetbrains/jet/storage/StorageManager.java +++ b/core/util.runtime/src/org/jetbrains/jet/storage/StorageManager.java @@ -18,6 +18,7 @@ package org.jetbrains.jet.storage; import jet.Function0; import jet.Function1; +import jet.Unit; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -28,6 +29,7 @@ public interface StorageManager { * @param valuesReferenceKind how to store the memoized values * * NOTE: if compute() has side-effects the WEAK reference kind is dangerous: the side-effects will be repeated if + * the value gets collected and then re-computed */ @NotNull MemoizedFunctionToNotNull createMemoizedFunction(@NotNull Function1 compute); @@ -41,7 +43,6 @@ public interface StorageManager { NotNullLazyValue createRecursionTolerantLazyValue(@NotNull Function0 computable, @NotNull T onRecursiveCall); /** - * @param computable * @param onRecursiveCall is called if the computation calls itself recursively. * The parameter to it is {@code true} for the first call, {@code false} otherwise. * If {@code onRecursiveCall} is {@code null}, an exception will be thrown on a recursive call, @@ -52,7 +53,7 @@ public interface StorageManager { NotNullLazyValue createLazyValueWithPostCompute( @NotNull Function0 computable, @Nullable Function1 onRecursiveCall, - @NotNull Function1 postCompute + @NotNull Function1 postCompute ); @NotNull @@ -66,7 +67,7 @@ public interface StorageManager { * see it in between) */ @NotNull - NullableLazyValue createNullableLazyValueWithPostCompute(@NotNull Function0 computable, @NotNull Function1 postCompute); + NullableLazyValue createNullableLazyValueWithPostCompute(@NotNull Function0 computable, @NotNull Function1 postCompute); T compute(@NotNull Function0 computable); }