ReenteringLazyValueComputationException & co moved to frontend

This commit is contained in:
Andrey Breslav
2013-10-04 20:49:52 +04:00
committed by Alexander Udalov
parent 0765e89b19
commit 2e585f88a3
8 changed files with 9 additions and 8 deletions
@@ -48,7 +48,7 @@ import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
import org.jetbrains.jet.lexer.JetTokens;
import org.jetbrains.jet.util.Box;
import org.jetbrains.jet.util.slicedmap.WritableSlice;
import org.jetbrains.jet.storage.ReenteringLazyValueComputationException;
import org.jetbrains.jet.util.ReenteringLazyValueComputationException;
import javax.inject.Inject;
import java.util.*;
@@ -19,7 +19,6 @@ package org.jetbrains.jet.lang.resolve;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.intellij.lang.ASTNode;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
@@ -54,7 +53,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.CONSTRUCTOR;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.*;
import static org.jetbrains.jet.lang.resolve.ModifiersChecker.*;
import static org.jetbrains.jet.lexer.JetTokens.OVERRIDE_KEYWORD;
import static org.jetbrains.jet.storage.StorageUtil.createRecursionIntolerantLazyValueWithDefault;
import static org.jetbrains.jet.util.StorageUtil.createRecursionIntolerantLazyValueWithDefault;
public class DescriptorResolver {
public static final Name COPY_METHOD_NAME = Name.identifier("copy");
@@ -23,7 +23,7 @@ import org.jetbrains.jet.lang.resolve.BindingTrace;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.storage.LockBasedStorageManager;
import org.jetbrains.jet.storage.NotNullLazyValue;
import org.jetbrains.jet.storage.ReenteringLazyValueComputationException;
import org.jetbrains.jet.util.ReenteringLazyValueComputationException;
import org.jetbrains.jet.util.Box;
import java.util.List;
@@ -45,7 +45,7 @@ import static org.jetbrains.jet.lang.resolve.BindingContext.*;
import static org.jetbrains.jet.lang.resolve.calls.context.ContextDependency.INDEPENDENT;
import static org.jetbrains.jet.lang.types.TypeUtils.*;
import static org.jetbrains.jet.lang.types.expressions.CoercionStrategy.COERCION_TO_UNIT;
import static org.jetbrains.jet.storage.StorageUtil.createRecursionIntolerantLazyValueWithDefault;
import static org.jetbrains.jet.util.StorageUtil.createRecursionIntolerantLazyValueWithDefault;
public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
protected ClosureExpressionsTypingVisitor(@NotNull ExpressionTypingInternals facade) {
@@ -27,7 +27,7 @@ import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
import org.jetbrains.jet.lang.types.DeferredType;
import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.JetTypeInfo;
import org.jetbrains.jet.storage.ReenteringLazyValueComputationException;
import org.jetbrains.jet.util.ReenteringLazyValueComputationException;
import static org.jetbrains.jet.lang.diagnostics.Errors.TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM;
@@ -0,0 +1,36 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.util;
import com.intellij.openapi.application.Application;
import com.intellij.openapi.application.ApplicationManager;
import org.jetbrains.annotations.NotNull;
public class ReenteringLazyValueComputationException extends RuntimeException {
public ReenteringLazyValueComputationException() {
}
@NotNull
@Override
public synchronized Throwable fillInStackTrace() {
Application application = ApplicationManager.getApplication();
if (application == null || application.isInternal() || application.isUnitTestMode()) {
return super.fillInStackTrace();
}
return this;
}
}
@@ -0,0 +1,52 @@
/*
* Copyright 2010-2013 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.jet.util;
import jet.Function0;
import jet.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.storage.NotNullLazyValue;
import static org.jetbrains.jet.storage.LockBasedStorageManager.NO_LOCKS;
public class StorageUtil {
private static final Function1 EMPTY_CONSUMER = new Function1<Object, Void>() {
@Override
public Void invoke(Object t) {
return null;
}
};
public static <T> NotNullLazyValue<T> createRecursionIntolerantLazyValueWithDefault(
@NotNull final T defaultValue,
@NotNull Function0<T> compute
) {
//noinspection unchecked
return NO_LOCKS.createLazyValueWithPostCompute(
compute,
new Function1<Boolean, T>() {
@Override
public T invoke(Boolean firstTime) {
if (firstTime) throw new ReenteringLazyValueComputationException();
return defaultValue;
}
},
EMPTY_CONSUMER
);
}
}
@@ -3,6 +3,7 @@ package org.jetbrains.jet.storage;
import jet.Function0;
import jet.Function1;
import junit.framework.TestCase;
import org.jetbrains.jet.util.ReenteringLazyValueComputationException;
import java.util.ArrayList;
import java.util.Arrays;