Remove lazy values with dummy post compute lambdas
This commit is contained in:
committed by
Nikolay Krasko
parent
fbde7e47e9
commit
4f488ddd16
+1
-1
@@ -134,7 +134,7 @@ class ClassResolutionScopesSupport(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun <T : Any> StorageManager.createLazyValue(onRecursion: ((Boolean) -> T), compute: () -> T) =
|
private fun <T : Any> StorageManager.createLazyValue(onRecursion: ((Boolean) -> T), compute: () -> T) =
|
||||||
createLazyValueWithPostCompute(compute, onRecursion, {})
|
createLazyValue(compute, onRecursion)
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val createErrorLexicalScope: (Boolean) -> LexicalScope = { ErrorLexicalScope() }
|
private val createErrorLexicalScope: (Boolean) -> LexicalScope = { ErrorLexicalScope() }
|
||||||
|
|||||||
@@ -52,9 +52,7 @@ public class DeferredType extends WrappedType {
|
|||||||
@NotNull BindingTrace trace,
|
@NotNull BindingTrace trace,
|
||||||
@NotNull Function0<KotlinType> compute
|
@NotNull Function0<KotlinType> compute
|
||||||
) {
|
) {
|
||||||
//noinspection unchecked
|
DeferredType deferredType = new DeferredType(storageManager.createLazyValue(compute, RECURSION_PREVENTER));
|
||||||
DeferredType deferredType =
|
|
||||||
new DeferredType(storageManager.createLazyValueWithPostCompute(compute, RECURSION_PREVENTER, t -> null));
|
|
||||||
trace.record(DEFERRED_TYPE, new Box<>(deferredType));
|
trace.record(DEFERRED_TYPE, new Box<>(deferredType));
|
||||||
return deferredType;
|
return deferredType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,21 @@ public class LockBasedStorageManager implements StorageManager {
|
|||||||
return new LockBasedNotNullLazyValue<T>(this, computable);
|
return new LockBasedNotNullLazyValue<T>(this, computable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public <T> NotNullLazyValue<T> createLazyValue(
|
||||||
|
@NotNull Function0<? extends T> computable,
|
||||||
|
@NotNull final Function1<? super Boolean, ? extends T> onRecursiveCall
|
||||||
|
) {
|
||||||
|
return new LockBasedNotNullLazyValue<T>(this, computable) {
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
protected RecursionDetectedResult<T> recursionDetected(boolean firstTime) {
|
||||||
|
return RecursionDetectedResult.value(onRecursiveCall.invoke(firstTime));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public <T> NotNullLazyValue<T> createRecursionTolerantLazyValue(
|
public <T> NotNullLazyValue<T> createRecursionTolerantLazyValue(
|
||||||
|
|||||||
@@ -50,6 +50,10 @@ abstract class ObservableStorageManager(private val delegate: StorageManager) :
|
|||||||
return delegate.createLazyValue(computable.observable)
|
return delegate.createLazyValue(computable.observable)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun <T: Any> createLazyValue(computable: () -> T, onRecursiveCall: (Boolean) -> T): NotNullLazyValue<T> {
|
||||||
|
return delegate.createLazyValue(computable.observable, onRecursiveCall)
|
||||||
|
}
|
||||||
|
|
||||||
override fun <T: Any> createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue<T> {
|
override fun <T: Any> createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue<T> {
|
||||||
return delegate.createRecursionTolerantLazyValue(computable.observable, onRecursiveCall)
|
return delegate.createRecursionTolerantLazyValue(computable.observable, onRecursiveCall)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ interface StorageManager {
|
|||||||
|
|
||||||
fun <T : Any> createLazyValue(computable: () -> T): NotNullLazyValue<T>
|
fun <T : Any> createLazyValue(computable: () -> T): NotNullLazyValue<T>
|
||||||
|
|
||||||
|
fun <T : Any> createLazyValue(computable: () -> T, onRecursiveCall: (Boolean) -> T): NotNullLazyValue<T>
|
||||||
|
|
||||||
fun <T : Any> createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue<T>
|
fun <T : Any> createRecursionTolerantLazyValue(computable: () -> T, onRecursiveCall: T): NotNullLazyValue<T>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user