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 56080d28afe..2c3660d339e 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 @@ -50,7 +50,6 @@ import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.storage.NotNullLazyValue; import org.jetbrains.jet.storage.NullableLazyValue; import org.jetbrains.jet.storage.StorageManager; -import org.jetbrains.jet.utils.WrappedValues; import java.util.*; @@ -397,10 +396,10 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc } } }, - new Function() { + new Function>() { @Override - public Object fun(Boolean firstTime) { - return WrappedValues.unescapeExceptionOrNull(Collections.emptyList()); + public Collection fun(Boolean firstTime) { + return Collections.emptyList(); } }, new Consumer>() { diff --git a/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java b/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java index 0865f060d2a..7e466c857a6 100644 --- a/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java +++ b/compiler/tests/org/jetbrains/jet/storage/StorageManagerTest.java @@ -4,7 +4,6 @@ import com.intellij.openapi.util.Computable; import com.intellij.util.Consumer; import com.intellij.util.Function; import junit.framework.TestCase; -import org.jetbrains.jet.utils.WrappedValues; import java.util.ArrayList; import java.util.Arrays; @@ -264,9 +263,9 @@ public class StorageManagerTest extends TestCase { return rec.compute(); } }, - new Function() { + new Function() { @Override - public Object fun(Boolean aBoolean) { + public String fun(Boolean aBoolean) { return "tolerant"; } }, @@ -347,11 +346,11 @@ public class StorageManagerTest extends TestCase { return rec.compute(); } }, - new Function() { + new Function() { @Override - public Object fun(Boolean firstTime) { + public String fun(Boolean firstTime) { if (firstTime) { - return WrappedValues.escapeThrowable(new ReenteringLazyValueComputationException()); + throw new ReenteringLazyValueComputationException(); } return "second"; } 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 4f9a51f9209..0811051f68e 100644 --- a/core/util.runtime/src/org/jetbrains/jet/storage/LockBasedStorageManager.java +++ b/core/util.runtime/src/org/jetbrains/jet/storage/LockBasedStorageManager.java @@ -84,7 +84,7 @@ public class LockBasedStorageManager implements StorageManager { ) { return new LockBasedNotNullLazyValue(lock, computable) { @Override - protected Object recursionDetected(boolean firstTime) { + protected T recursionDetected(boolean firstTime) { return onRecursiveCall; } }; @@ -94,13 +94,13 @@ public class LockBasedStorageManager implements StorageManager { @Override public NotNullLazyValue createLazyValueWithPostCompute( @NotNull Computable computable, - final Function onRecursiveCall, + final Function onRecursiveCall, @NotNull final Consumer postCompute ) { return new LockBasedNotNullLazyValue(lock, computable) { @Nullable @Override - protected Object recursionDetected(boolean firstTime) { + protected T recursionDetected(boolean firstTime) { if (onRecursiveCall == null) { return super.recursionDetected(firstTime); } @@ -125,7 +125,7 @@ public class LockBasedStorageManager implements StorageManager { public NullableLazyValue createRecursionTolerantNullableLazyValue(@NotNull Computable computable, final T onRecursiveCall) { return new LockBasedLazyValue(lock, computable) { @Override - protected Object recursionDetected(boolean firstTime) { + protected T recursionDetected(boolean firstTime) { return onRecursiveCall; } }; @@ -191,11 +191,11 @@ public class LockBasedStorageManager implements StorageManager { if (_value == NotValue.COMPUTING) { value = NotValue.RECURSION_WAS_DETECTED; - return WrappedValues.unescapeThrowable(recursionDetected(/*firstTime = */ true)); + return recursionDetected(/*firstTime = */ true); } if (_value == NotValue.RECURSION_WAS_DETECTED) { - return WrappedValues.unescapeThrowable(recursionDetected(/*firstTime = */ false)); + return recursionDetected(/*firstTime = */ false); } value = NotValue.COMPUTING; @@ -220,12 +220,11 @@ public class LockBasedStorageManager implements StorageManager { /** * @param firstTime {@code true} when recursion has been just detected, {@code false} otherwise - * @return a value or wrapped exception, see WrappedValues - * @throws DO NOT throw exceptions from implementations of this method, instead return WrappedValues.escapeThrowable(exception) + * @return a value to be returned on a recursive call or subsequent calls */ @Nullable - protected Object recursionDetected(boolean firstTime) { - return WrappedValues.escapeThrowable(new IllegalStateException("Recursive call in a lazy value")); + protected T recursionDetected(boolean firstTime) { + throw new IllegalStateException("Recursive call in a lazy value"); } protected void postCompute(T value) { 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 6f92c366abf..f1e18c03597 100644 --- a/core/util.runtime/src/org/jetbrains/jet/storage/StorageManager.java +++ b/core/util.runtime/src/org/jetbrains/jet/storage/StorageManager.java @@ -46,13 +46,13 @@ public interface StorageManager { * @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, - * otherwise it should return a result of WrappedValues.escapeThrowable() method + * otherwise it's executed and its result is returned * @param postCompute is called after the value is computed, but before any other thread sees it */ @NotNull NotNullLazyValue createLazyValueWithPostCompute( @NotNull Computable computable, - @Nullable Function onRecursiveCall, + @Nullable Function onRecursiveCall, @NotNull Consumer postCompute ); diff --git a/core/util.runtime/src/org/jetbrains/jet/storage/StorageUtil.java b/core/util.runtime/src/org/jetbrains/jet/storage/StorageUtil.java index 26188e01ca4..d31fe3a6040 100644 --- a/core/util.runtime/src/org/jetbrains/jet/storage/StorageUtil.java +++ b/core/util.runtime/src/org/jetbrains/jet/storage/StorageUtil.java @@ -20,7 +20,8 @@ import com.intellij.openapi.util.Computable; import com.intellij.util.Consumer; import com.intellij.util.Function; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.utils.WrappedValues; + +import static org.jetbrains.jet.storage.LockBasedStorageManager.NO_LOCKS; public class StorageUtil { public static NotNullLazyValue createRecursionIntolerantLazyValueWithDefault( @@ -28,12 +29,12 @@ public class StorageUtil { @NotNull Computable compute ) { //noinspection unchecked - return LockBasedStorageManager.NO_LOCKS.createLazyValueWithPostCompute( + return NO_LOCKS.createLazyValueWithPostCompute( compute, - new Function() { + new Function() { @Override - public Object fun(Boolean firstTime) { - if (firstTime) return WrappedValues.escapeThrowable(new ReenteringLazyValueComputationException()); + public T fun(Boolean firstTime) { + if (firstTime) throw new ReenteringLazyValueComputationException(); return defaultValue; } },