diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TraceUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TraceUtil.java new file mode 100644 index 00000000000..f83f5df34c3 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TraceUtil.java @@ -0,0 +1,118 @@ +/* + * 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 com.google.common.collect.ImmutableMap; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.lang.diagnostics.Diagnostic; +import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; +import org.jetbrains.jet.util.slicedmap.WritableSlice; + +import java.util.Collection; + +public class TraceUtil { + public final static BindingTrace TRACE_STUB = new BindingTrace() { + + @Override + public BindingContext getBindingContext() { + return BINDING_CONTEXT_STUB; + } + + @Override + public void record(WritableSlice slice, K key, V value) { + throw new IllegalStateException(); + } + + @Override + public void record(WritableSlice slice, K key) { + throw new IllegalStateException(); + } + + @Nullable + @Override + public V get(ReadOnlySlice slice, K key) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + throw new IllegalStateException(); + } + + @Override + public void report(@NotNull Diagnostic diagnostic) { + throw new IllegalStateException(); + } + }; + + public final static BindingContext BINDING_CONTEXT_STUB = new BindingContext() { + @Override + public Collection getDiagnostics() { + throw new IllegalStateException(); + } + + @Nullable + @Override + public V get(ReadOnlySlice slice, K key) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public ImmutableMap getSliceContents(@NotNull ReadOnlySlice slice) { + throw new IllegalStateException(); + } + }; + + public final static DelegatingBindingTrace DELEGATING_TRACE_STUB = new DelegatingBindingTrace(BINDING_CONTEXT_STUB, "Delegating trace stub") { + + @Override + public void record(WritableSlice slice, K key, V value) { + throw new IllegalStateException(); + } + + @Override + public void record(WritableSlice slice, K key) { + throw new IllegalStateException(); + } + + @Nullable + @Override + public V get(ReadOnlySlice slice, K key) { + throw new IllegalStateException(); + } + + @NotNull + @Override + public Collection getKeys(WritableSlice slice) { + throw new IllegalStateException(); + } + + @Override + public void report(@NotNull Diagnostic diagnostic) { + throw new IllegalStateException(); + } + }; +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java index 441b477072f..68444b9e7e3 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolverUtil.java @@ -22,7 +22,7 @@ import org.jetbrains.jet.lang.descriptors.CallableDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor; import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.resolve.TemporaryBindingTrace; +import org.jetbrains.jet.lang.resolve.TraceUtil; import org.jetbrains.jet.lang.resolve.calls.context.CallResolutionContext; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystem; import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintsUtil; @@ -55,10 +55,7 @@ public class CallResolverUtil { call.getReceiverArgument(), call.getExplicitReceiverKind(), call.isSafeCall()); - TemporaryBindingTrace trace = TemporaryBindingTrace.create(context.trace, call.getTrace().toString() + "(copy)"); - ResolvedCallImpl copy = ResolvedCallImpl.create(candidate, trace, call.getTracing()); - //todo remove because call's trace isn't used (?) - call.getTrace().addAllMyDataTo(trace); + ResolvedCallImpl copy = ResolvedCallImpl.create(candidate, TraceUtil.DELEGATING_TRACE_STUB, call.getTracing()); context.trace.record(BindingContext.RESOLVED_CALL, context.call.getCalleeExpression(), copy); copy.addStatus(call.getStatus()); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TypeInfoForCall.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TypeInfoForCall.java index f624b8347f1..c71ea864c9c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TypeInfoForCall.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/context/TypeInfoForCall.java @@ -19,60 +19,16 @@ package org.jetbrains.jet.lang.resolve.calls.context; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; -import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.psi.Call; -import org.jetbrains.jet.lang.resolve.BindingContext; -import org.jetbrains.jet.lang.resolve.BindingTrace; -import org.jetbrains.jet.lang.resolve.BindingTraceContext; +import org.jetbrains.jet.lang.resolve.TraceUtil; import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCallImpl; -import org.jetbrains.jet.lang.resolve.calls.tasks.TracingStrategy; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.JetTypeInfo; -import org.jetbrains.jet.lang.types.TypeUtils; -import org.jetbrains.jet.util.slicedmap.ReadOnlySlice; -import org.jetbrains.jet.util.slicedmap.WritableSlice; - -import java.util.Collection; public class TypeInfoForCall { - private final static BindingTrace TRACE_STUB = new BindingTrace() { - - @Override - public BindingContext getBindingContext() { - throw new UnsupportedOperationException(); - } - - @Override - public void record(WritableSlice slice, K key, V value) { - throw new UnsupportedOperationException(); - } - - @Override - public void record(WritableSlice slice, K key) { - throw new UnsupportedOperationException(); - } - - @Nullable - @Override - public V get(ReadOnlySlice slice, K key) { - throw new UnsupportedOperationException(); - } - - @NotNull - @Override - public Collection getKeys(WritableSlice slice) { - throw new UnsupportedOperationException(); - } - - @Override - public void report(@NotNull Diagnostic diagnostic) { - throw new UnsupportedOperationException(); - } - }; - private final JetTypeInfo typeInfo; private final CallCandidateResolutionContext callCandidateResolutionContext; @@ -97,7 +53,7 @@ public class TypeInfoForCall { if (resolvedCall instanceof ResolvedCallImpl) { //todo[ResolvedCallImpl] callCandidateResolutionContext = CallCandidateResolutionContext.createForCallBeingAnalyzed( - (ResolvedCallImpl) resolvedCall, context.replaceBindingTrace(TRACE_STUB), + (ResolvedCallImpl) resolvedCall, context.replaceBindingTrace(TraceUtil.TRACE_STUB), call, resolveMode, ((ResolvedCallImpl) resolvedCall).getTracing()); } else {