Got rid of HAS_TAIL_CALL slice
This commit is contained in:
@@ -691,13 +691,14 @@ public class JetFlowInformationProvider {
|
||||
}
|
||||
}
|
||||
);
|
||||
boolean hasTailCalls = false;
|
||||
for (Map.Entry<JetElement, KindAndCall> entry : calls.entrySet()) {
|
||||
JetElement element = entry.getKey();
|
||||
KindAndCall kindAndCall = entry.getValue();
|
||||
switch (kindAndCall.kind) {
|
||||
case TAIL_CALL:
|
||||
trace.record(TAIL_RECURSION_CALL, kindAndCall.call, TailRecursionKind.TAIL_CALL);
|
||||
trace.record(BindingContext.HAS_TAIL_CALLS, (FunctionDescriptor) subroutineDescriptor);
|
||||
hasTailCalls = true;
|
||||
break;
|
||||
case IN_TRY:
|
||||
trace.report(Errors.TAIL_RECURSION_IN_TRY_IS_NOT_SUPPORTED.on(element));
|
||||
@@ -706,7 +707,10 @@ public class JetFlowInformationProvider {
|
||||
trace.report(Errors.NON_TAIL_RECURSIVE_CALL.on(element));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasTailCalls) {
|
||||
trace.report(Errors.NO_TAIL_CALLS_FOUND.on((JetNamedFunction) subroutine));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -21,11 +21,11 @@ import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.lang.resolve.calls.TailRecursionKind;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptorImpl;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.resolve.calls.TailRecursionKind;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemCompleter;
|
||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||
@@ -40,7 +40,6 @@ import org.jetbrains.jet.util.slicedmap.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.util.slicedmap.RewritePolicy.DO_NOTHING;
|
||||
|
||||
@@ -90,7 +89,6 @@ public interface BindingContext {
|
||||
WritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>> RESOLVED_CALL =
|
||||
new BasicWritableSlice<JetElement, ResolvedCall<? extends CallableDescriptor>>(DO_NOTHING);
|
||||
WritableSlice<ResolvedCall<?>, TailRecursionKind> TAIL_RECURSION_CALL = Slices.createSimpleSlice();
|
||||
WritableSlice<FunctionDescriptor, Boolean> HAS_TAIL_CALLS = Slices.createSimpleSetSlice();
|
||||
WritableSlice<JetElement, ConstraintSystemCompleter> CONSTRAINT_SYSTEM_COMPLETER = new BasicWritableSlice<JetElement, ConstraintSystemCompleter>(DO_NOTHING);
|
||||
WritableSlice<JetElement, Call> CALL = new BasicWritableSlice<JetElement, Call>(DO_NOTHING);
|
||||
|
||||
|
||||
@@ -63,9 +63,6 @@ public class FunctionAnalyzerExtension {
|
||||
((SimpleFunctionDescriptor) functionDescriptor).isInline()) {
|
||||
list.add(InlineAnalyzerExtension.INSTANCE);
|
||||
}
|
||||
if (KotlinBuiltIns.getInstance().isTailRecursive(functionDescriptor)) {
|
||||
list.add(TailRecursionsFunctionAnalyzerExtension.INSTANCE);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
-38
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* 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.lang.resolve;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
import org.jetbrains.jet.lang.diagnostics.Errors;
|
||||
import org.jetbrains.jet.lang.psi.JetNamedFunction;
|
||||
|
||||
public class TailRecursionsFunctionAnalyzerExtension implements FunctionAnalyzerExtension.AnalyzerExtension {
|
||||
|
||||
public static final TailRecursionsFunctionAnalyzerExtension INSTANCE = new TailRecursionsFunctionAnalyzerExtension();
|
||||
|
||||
@Override
|
||||
public void process(
|
||||
@NotNull FunctionDescriptor descriptor, @NotNull JetNamedFunction function, @NotNull BindingTrace trace
|
||||
) {
|
||||
Boolean hasTailCalls = trace.get(BindingContext.HAS_TAIL_CALLS, descriptor);
|
||||
|
||||
if (Boolean.FALSE.equals(hasTailCalls)) {
|
||||
trace.report(Errors.NO_TAIL_CALLS_FOUND.on(function));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user