001    /*
002     * Copyright 2010-2017 JetBrains s.r.o.
003     *
004     * Licensed under the Apache License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.apache.org/licenses/LICENSE-2.0
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    
017    package org.jetbrains.kotlin.types.expressions;
018    
019    import com.google.common.collect.ImmutableMap;
020    import com.google.common.collect.Lists;
021    import com.google.common.collect.Maps;
022    import com.intellij.lang.ASTNode;
023    import com.intellij.openapi.diagnostic.Logger;
024    import com.intellij.openapi.util.Ref;
025    import com.intellij.psi.util.PsiTreeUtil;
026    import org.jetbrains.annotations.NotNull;
027    import org.jetbrains.annotations.Nullable;
028    import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
029    import org.jetbrains.kotlin.descriptors.*;
030    import org.jetbrains.kotlin.descriptors.annotations.Annotations;
031    import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
032    import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl;
033    import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl;
034    import org.jetbrains.kotlin.lexer.KtTokens;
035    import org.jetbrains.kotlin.name.Name;
036    import org.jetbrains.kotlin.psi.*;
037    import org.jetbrains.kotlin.resolve.BindingContextUtils;
038    import org.jetbrains.kotlin.resolve.BindingTrace;
039    import org.jetbrains.kotlin.resolve.calls.CallResolver;
040    import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext;
041    import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
042    import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemStatus;
043    import org.jetbrains.kotlin.resolve.calls.inference.ConstraintsUtil;
044    import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData;
045    import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments;
046    import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
047    import org.jetbrains.kotlin.resolve.calls.results.OverloadResolutionResults;
048    import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
049    import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind;
050    import org.jetbrains.kotlin.resolve.calls.tasks.ResolutionCandidate;
051    import org.jetbrains.kotlin.resolve.calls.tasks.TracingStrategy;
052    import org.jetbrains.kotlin.resolve.calls.util.CallMaker;
053    import org.jetbrains.kotlin.resolve.descriptorUtil.AnnotationsForResolveKt;
054    import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue;
055    import org.jetbrains.kotlin.types.*;
056    import org.jetbrains.kotlin.types.typeUtil.TypeUtilsKt;
057    
058    import java.util.*;
059    
060    import static org.jetbrains.kotlin.diagnostics.Errors.TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT;
061    import static org.jetbrains.kotlin.resolve.BindingContext.CALL;
062    import static org.jetbrains.kotlin.resolve.BindingContext.RESOLVED_CALL;
063    import static org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.EXPECTED_TYPE_POSITION;
064    
065    public class ControlStructureTypingUtils {
066        private static final Logger LOG = Logger.getInstance(ControlStructureTypingUtils.class);
067    
068        public enum ResolveConstruct {
069            IF("if"), ELVIS("elvis"), EXCL_EXCL("ExclExcl"), WHEN("when");
070    
071            private final String name;
072    
073            ResolveConstruct(String name) {
074                this.name = name;
075            }
076    
077            public String getName() {
078                return name;
079            }
080    
081            public Name getSpecialFunctionName() {
082                return Name.identifier("<SPECIAL-FUNCTION-FOR-" + name.toUpperCase() + "-RESOLVE>");
083            }
084    
085            public Name getSpecialTypeParameterName() {
086                return Name.identifier("<TYPE-PARAMETER-FOR-" + name.toUpperCase() + "-RESOLVE>");
087            }
088        }
089    
090        private final CallResolver callResolver;
091        private final DataFlowAnalyzer dataFlowAnalyzer;
092        private final ModuleDescriptor moduleDescriptor;
093    
094        public ControlStructureTypingUtils(
095                @NotNull CallResolver callResolver,
096                @NotNull DataFlowAnalyzer dataFlowAnalyzer,
097                @NotNull ModuleDescriptor moduleDescriptor
098        ) {
099            this.callResolver = callResolver;
100            this.dataFlowAnalyzer = dataFlowAnalyzer;
101            this.moduleDescriptor = moduleDescriptor;
102        }
103    
104        /*package*/ ResolvedCall<FunctionDescriptor> resolveSpecialConstructionAsCall(
105                @NotNull Call call,
106                @NotNull ResolveConstruct construct,
107                @NotNull List<String> argumentNames,
108                @NotNull List<Boolean> isArgumentNullable,
109                @NotNull ExpressionTypingContext context,
110                @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments
111        ) {
112            SimpleFunctionDescriptorImpl function = createFunctionDescriptorForSpecialConstruction(
113                    construct, argumentNames, isArgumentNullable);
114            TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
115            TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType);
116            ResolutionCandidate<FunctionDescriptor> resolutionCandidate =
117                    ResolutionCandidate.<FunctionDescriptor>create(call, function, knownTypeParameterSubstitutor);
118            OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate(
119                    call, tracing, context, resolutionCandidate, dataFlowInfoForArguments);
120            assert results.isSingleResult() : "Not single result after resolving one known candidate";
121            return results.getResultingCall();
122        }
123    
124        private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(
125                @NotNull ResolveConstruct construct,
126                @NotNull SimpleFunctionDescriptorImpl function,
127                @NotNull KotlinType expectedType
128        ) {
129            if (construct == ResolveConstruct.ELVIS
130                || TypeUtils.noExpectedType(expectedType)
131                || TypeUtils.isDontCarePlaceholder(expectedType)
132                || KotlinBuiltIns.isUnitOrNullableUnit(expectedType)
133                || KotlinBuiltIns.isAnyOrNullableAny(expectedType)
134                    ) {
135                return null;
136            }
137    
138            TypeConstructor typeParameterConstructor = function.getTypeParameters().get(0).getTypeConstructor();
139            TypeProjection typeProjection = new TypeProjectionImpl(expectedType);
140            return TypeSubstitutor.create(ImmutableMap.of(typeParameterConstructor, typeProjection));
141        }
142    
143        private SimpleFunctionDescriptorImpl createFunctionDescriptorForSpecialConstruction(
144                @NotNull ResolveConstruct construct,
145                @NotNull List<String> argumentNames,
146                @NotNull List<Boolean> isArgumentNullable
147        ) {
148            assert argumentNames.size() == isArgumentNullable.size();
149    
150            SimpleFunctionDescriptorImpl function = SimpleFunctionDescriptorImpl.create(
151                    moduleDescriptor, Annotations.Companion.getEMPTY(), construct.getSpecialFunctionName(),
152                    CallableMemberDescriptor.Kind.DECLARATION, SourceElement.NO_SOURCE
153            );
154    
155            TypeParameterDescriptor typeParameter = TypeParameterDescriptorImpl.createWithDefaultBound(
156                    function, Annotations.Companion.getEMPTY(), false, Variance.INVARIANT,
157                    construct.getSpecialTypeParameterName(), 0);
158    
159            KotlinType type = typeParameter.getDefaultType();
160            KotlinType nullableType = TypeUtils.makeNullable(type);
161    
162            List<ValueParameterDescriptor> valueParameters = new ArrayList<ValueParameterDescriptor>(argumentNames.size());
163            for (int i = 0; i < argumentNames.size(); i++) {
164                KotlinType argumentType = isArgumentNullable.get(i) ? nullableType : type;
165                ValueParameterDescriptorImpl valueParameter = new ValueParameterDescriptorImpl(
166                        function, null, i, Annotations.Companion.getEMPTY(), Name.identifier(argumentNames.get(i)),
167                        argumentType,
168                        /* declaresDefaultValue = */ false,
169                        /* isCrossinline = */ false,
170                        /* isNoinline = */ false,
171                        null, SourceElement.NO_SOURCE
172                );
173                valueParameters.add(valueParameter);
174            }
175            KotlinType returnType = construct != ResolveConstruct.ELVIS ? type : TypeUtilsKt.replaceAnnotations(type, AnnotationsForResolveKt.getExactInAnnotations());
176            function.initialize(
177                    null,
178                    null,
179                    Lists.newArrayList(typeParameter),
180                    valueParameters,
181                    returnType,
182                    Modality.FINAL,
183                    Visibilities.PUBLIC
184            );
185            return function;
186        }
187    
188        private static MutableDataFlowInfoForArguments createIndependentDataFlowInfoForArgumentsForCall(
189                @NotNull DataFlowInfo initialDataFlowInfo,
190                final Map<ValueArgument, DataFlowInfo> dataFlowInfoForArgumentsMap
191        ) {
192            return new MutableDataFlowInfoForArguments(initialDataFlowInfo) {
193    
194                @Override
195                public void updateInfo(@NotNull ValueArgument valueArgument, @NotNull DataFlowInfo dataFlowInfo) {
196                    dataFlowInfoForArgumentsMap.put(valueArgument, dataFlowInfo);
197                }
198    
199                @NotNull
200                @Override
201                public DataFlowInfo getInfo(@NotNull ValueArgument valueArgument) {
202                    return dataFlowInfoForArgumentsMap.get(valueArgument);
203                }
204            };
205        }
206    
207        public static MutableDataFlowInfoForArguments createDataFlowInfoForArgumentsForIfCall(
208                @NotNull Call callForIf,
209                @NotNull DataFlowInfo conditionInfo,
210                @NotNull DataFlowInfo thenInfo,
211                @NotNull DataFlowInfo elseInfo
212        ) {
213            Map<ValueArgument, DataFlowInfo> dataFlowInfoForArgumentsMap = Maps.newHashMap();
214            dataFlowInfoForArgumentsMap.put(callForIf.getValueArguments().get(0), thenInfo);
215            dataFlowInfoForArgumentsMap.put(callForIf.getValueArguments().get(1), elseInfo);
216            return createIndependentDataFlowInfoForArgumentsForCall(conditionInfo, dataFlowInfoForArgumentsMap);
217        }
218    
219        public static MutableDataFlowInfoForArguments createDataFlowInfoForArgumentsOfWhenCall(
220                @NotNull Call callForWhen,
221                @NotNull DataFlowInfo subjectDataFlowInfo,
222                @NotNull List<DataFlowInfo> entryDataFlowInfos
223        ) {
224            Map<ValueArgument, DataFlowInfo> dataFlowInfoForArgumentsMap = Maps.newHashMap();
225            int i = 0;
226            for (ValueArgument argument : callForWhen.getValueArguments()) {
227                DataFlowInfo entryDataFlowInfo = entryDataFlowInfos.get(i++);
228                dataFlowInfoForArgumentsMap.put(argument, entryDataFlowInfo);
229            }
230            return createIndependentDataFlowInfoForArgumentsForCall(subjectDataFlowInfo, dataFlowInfoForArgumentsMap);
231        }
232    
233        /*package*/ static Call createCallForSpecialConstruction(
234                @NotNull final KtExpression expression,
235                @NotNull final KtExpression calleeExpression,
236                @NotNull List<? extends KtExpression> arguments
237        ) {
238            final List<ValueArgument> valueArguments = Lists.newArrayList();
239            for (KtExpression argument : arguments) {
240                valueArguments.add(CallMaker.makeValueArgument(argument));
241            }
242            return new Call() {
243                @Nullable
244                @Override
245                public ASTNode getCallOperationNode() {
246                    return expression.getNode();
247                }
248    
249                @Nullable
250                @Override
251                public ReceiverValue getExplicitReceiver() {
252                    return null;
253                }
254    
255                @Nullable
256                @Override
257                public ReceiverValue getDispatchReceiver() {
258                    return null;
259                }
260    
261                @Nullable
262                @Override
263                public KtExpression getCalleeExpression() {
264                    return calleeExpression;
265                }
266    
267                @Nullable
268                @Override
269                public KtValueArgumentList getValueArgumentList() {
270                    return null;
271                }
272    
273                @NotNull
274                @Override
275                public List<? extends ValueArgument> getValueArguments() {
276                    return valueArguments;
277                }
278    
279                @NotNull
280                @Override
281                public List<LambdaArgument> getFunctionLiteralArguments() {
282                    return Collections.emptyList();
283                }
284    
285                @NotNull
286                @Override
287                public List<KtTypeProjection> getTypeArguments() {
288                    return Collections.emptyList();
289                }
290    
291                @Nullable
292                @Override
293                public KtTypeArgumentList getTypeArgumentList() {
294                    return null;
295                }
296    
297                @NotNull
298                @Override
299                public KtElement getCallElement() {
300                    return expression;
301                }
302    
303                @NotNull
304                @Override
305                public CallType getCallType() {
306                    return CallType.DEFAULT;
307                }
308            };
309        }
310    
311        @NotNull
312        private TracingStrategy createTracingForSpecialConstruction(
313                final @NotNull Call call,
314                @NotNull String constructionName,
315                final @NotNull ExpressionTypingContext context
316        ) {
317            class CheckTypeContext {
318                public BindingTrace trace;
319                public KotlinType expectedType;
320    
321                CheckTypeContext(@NotNull BindingTrace trace, @NotNull KotlinType expectedType) {
322                    this.trace = trace;
323                    this.expectedType = expectedType;
324                }
325    
326                CheckTypeContext makeTypeNullable() {
327                    if (TypeUtils.noExpectedType(expectedType)) return this;
328                    return new CheckTypeContext(trace, TypeUtils.makeNullable(expectedType));
329                }
330            }
331    
332            final KtVisitor<Boolean, CheckTypeContext> checkTypeVisitor = new KtVisitor<Boolean, CheckTypeContext>() {
333    
334                private boolean checkExpressionType(@NotNull KtExpression expression, CheckTypeContext c) {
335                    KotlinTypeInfo typeInfo = BindingContextUtils.getRecordedTypeInfo(expression, c.trace.getBindingContext());
336                    if (typeInfo == null) return false;
337    
338                    Ref<Boolean> hasError = Ref.create();
339                    dataFlowAnalyzer.checkType(
340                            typeInfo.getType(),
341                            expression,
342                            context
343                                    .replaceExpectedType(c.expectedType)
344                                    .replaceDataFlowInfo(typeInfo.getDataFlowInfo())
345                                    .replaceBindingTrace(c.trace),
346                            hasError
347                    );
348                    return hasError.get();
349                }
350    
351                private boolean checkExpressionTypeRecursively(@Nullable KtExpression expression, CheckTypeContext c) {
352                    if (expression == null) return false;
353                    return expression.accept(this, c);
354                }
355    
356                private boolean checkSubExpressions(
357                        KtExpression firstSub, KtExpression secondSub, KtExpression expression,
358                        CheckTypeContext firstContext, CheckTypeContext secondContext, CheckTypeContext context
359                ) {
360                    boolean errorWasReported = checkExpressionTypeRecursively(firstSub, firstContext);
361                    errorWasReported |= checkExpressionTypeRecursively(secondSub, secondContext);
362                    return errorWasReported || checkExpressionType(expression, context);
363                }
364    
365                @Override
366                public Boolean visitWhenExpression(@NotNull KtWhenExpression whenExpression, CheckTypeContext c) {
367                    boolean errorWasReported = false;
368                    for (KtWhenEntry whenEntry : whenExpression.getEntries()) {
369                        KtExpression entryExpression = whenEntry.getExpression();
370                        if (entryExpression != null) {
371                            errorWasReported |= checkExpressionTypeRecursively(entryExpression, c);
372                        }
373                    }
374                    errorWasReported |= checkExpressionType(whenExpression, c);
375                    return errorWasReported;
376                }
377    
378                @Override
379                public Boolean visitIfExpression(@NotNull KtIfExpression ifExpression, CheckTypeContext c) {
380                    KtExpression thenBranch = ifExpression.getThen();
381                    KtExpression elseBranch = ifExpression.getElse();
382                    if (thenBranch == null || elseBranch == null) {
383                        return checkExpressionType(ifExpression, c);
384                    }
385                    return checkSubExpressions(thenBranch, elseBranch, ifExpression, c, c, c);
386                }
387    
388                @Override
389                public Boolean visitBlockExpression(@NotNull KtBlockExpression expression, CheckTypeContext c) {
390                    if (expression.getStatements().isEmpty()) {
391                        return checkExpressionType(expression, c);
392                    }
393                    KtExpression lastStatement = KtPsiUtil.getLastStatementInABlock(expression);
394                    if (lastStatement != null) {
395                        return checkExpressionTypeRecursively(lastStatement, c);
396                    }
397                    return false;
398                }
399    
400                @Override
401                public Boolean visitPostfixExpression(@NotNull KtPostfixExpression expression, CheckTypeContext c) {
402                    if (expression.getOperationReference().getReferencedNameElementType() == KtTokens.EXCLEXCL) {
403                        return checkExpressionTypeRecursively(expression.getBaseExpression(), c.makeTypeNullable());
404                    }
405                    return super.visitPostfixExpression(expression, c);
406                }
407    
408                @Override
409                public Boolean visitBinaryExpression(@NotNull KtBinaryExpression expression, CheckTypeContext c) {
410                    if (expression.getOperationReference().getReferencedNameElementType() == KtTokens.ELVIS) {
411    
412                        return checkSubExpressions(expression.getLeft(), expression.getRight(), expression, c.makeTypeNullable(), c, c);
413                    }
414                    return super.visitBinaryExpression(expression, c);
415                }
416    
417                @Override
418                public Boolean visitExpression(@NotNull KtExpression expression, CheckTypeContext c) {
419                    return checkExpressionType(expression, c);
420                }
421            };
422    
423            return new ThrowingOnErrorTracingStrategy("resolve " + constructionName + " as a call") {
424                @Override
425                public <D extends CallableDescriptor> void bindReference(
426                        @NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall
427                ) {
428                    //do nothing
429                }
430    
431                @Override
432                public void bindCall(@NotNull BindingTrace trace, @NotNull Call call) {
433                    trace.record(CALL, call.getCalleeExpression(), call);
434                }
435    
436                @Override
437                public <D extends CallableDescriptor> void bindResolvedCall(
438                        @NotNull BindingTrace trace, @NotNull ResolvedCall<D> resolvedCall
439                ) {
440                    trace.record(RESOLVED_CALL, call, resolvedCall);
441                }
442    
443                @Override
444                public void typeInferenceFailed(
445                        @NotNull ResolutionContext<?> context, @NotNull InferenceErrorData data
446                ) {
447                    ConstraintSystem constraintSystem = data.constraintSystem;
448                    ConstraintSystemStatus status = constraintSystem.getStatus();
449                    assert !status.isSuccessful() : "Report error only for not successful constraint system";
450    
451                    if (status.hasErrorInConstrainingTypes() || status.hasUnknownParameters()) {
452                        return;
453                    }
454                    KtExpression expression = (KtExpression) call.getCallElement();
455                    if (status.hasOnlyErrorsDerivedFrom(EXPECTED_TYPE_POSITION) || status.hasConflictingConstraints()
456                            || status.hasTypeInferenceIncorporationError()) { // todo after KT-... remove this line
457                        if (noTypeCheckingErrorsInExpression(expression, context.trace, data.expectedType)) {
458                            KtExpression calleeExpression = call.getCalleeExpression();
459                            if (calleeExpression instanceof KtWhenExpression || calleeExpression instanceof KtIfExpression) {
460                                if (status.hasConflictingConstraints() || status.hasTypeInferenceIncorporationError()) {
461                                    // TODO provide comprehensible error report for hasConflictingConstraints() case (if possible)
462                                    context.trace.report(TYPE_INFERENCE_FAILED_ON_SPECIAL_CONSTRUCT.on(expression));
463                                }
464                            }
465                        }
466                        return;
467                    }
468                    KtDeclaration parentDeclaration = PsiTreeUtil.getParentOfType(expression, KtNamedDeclaration.class);
469                    logError("Expression: " + (parentDeclaration != null ? parentDeclaration.getText() : expression.getText()) +
470                             "\nConstraint system status: \n" + ConstraintsUtil.getDebugMessageForStatus(status));
471                }
472    
473                private boolean noTypeCheckingErrorsInExpression(
474                        KtExpression expression,
475                        @NotNull BindingTrace trace,
476                        @NotNull KotlinType expectedType
477                ) {
478                    return Boolean.TRUE != expression.accept(checkTypeVisitor, new CheckTypeContext(trace, expectedType));
479                }
480            };
481        }
482    
483        private abstract static class ThrowingOnErrorTracingStrategy implements TracingStrategy {
484            private final String debugName;
485    
486            protected ThrowingOnErrorTracingStrategy(String debugName) {
487                this.debugName = debugName;
488            }
489    
490            private void logError() {
491                logError(null);
492            }
493    
494            protected void logError(@Nullable String additionalInformation) {
495                String errorMessage = "Resolution error of this type shouldn't occur for " + debugName;
496                if (additionalInformation != null) {
497                    errorMessage += ".\n" + additionalInformation;
498                }
499                LOG.error(errorMessage);
500            }
501    
502            @Override
503            public void unresolvedReference(@NotNull BindingTrace trace) {
504                logError();
505            }
506    
507            @Override
508            public <D extends CallableDescriptor> void unresolvedReferenceWrongReceiver(
509                    @NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> candidates
510            ) {
511                logError();
512            }
513    
514            @Override
515            public <D extends CallableDescriptor> void recordAmbiguity(
516                    @NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> candidates
517            ) {
518                logError();
519            }
520    
521            @Override
522            public void missingReceiver(
523                    @NotNull BindingTrace trace, @NotNull ReceiverParameterDescriptor expectedReceiver
524            ) {
525                logError();
526            }
527    
528            @Override
529            public void wrongReceiverType(
530                    @NotNull BindingTrace trace,
531                    @NotNull ReceiverParameterDescriptor receiverParameter,
532                    @NotNull ReceiverValue receiverArgument,
533                    @NotNull ResolutionContext<?> c
534            ) {
535                logError();
536            }
537    
538            @Override
539            public void noReceiverAllowed(@NotNull BindingTrace trace) {
540                logError();
541            }
542    
543            @Override
544            public void noValueForParameter(
545                    @NotNull BindingTrace trace, @NotNull ValueParameterDescriptor valueParameter
546            ) {
547                logError();
548            }
549    
550            @Override
551            public void wrongNumberOfTypeArguments(@NotNull BindingTrace trace, int expectedTypeArgumentCount, @NotNull CallableDescriptor descriptor) {
552                logError();
553            }
554    
555            @Override
556            public <D extends CallableDescriptor> void ambiguity(
557                    @NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors
558            ) {
559                logError();
560            }
561    
562            @Override
563            public <D extends CallableDescriptor> void noneApplicable(
564                    @NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors
565            ) {
566                logError();
567            }
568    
569            @Override
570            public <D extends CallableDescriptor> void cannotCompleteResolve(
571                    @NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> descriptors
572            ) {
573                logError();
574            }
575    
576            @Override
577            public void instantiationOfAbstractClass(@NotNull BindingTrace trace) {
578                logError();
579            }
580    
581            @Override
582            public void abstractSuperCall(@NotNull BindingTrace trace) {
583                logError();
584            }
585    
586            @Override
587            public void nestedClassAccessViaInstanceReference(
588                    @NotNull BindingTrace trace, @NotNull ClassDescriptor classDescriptor,
589                    @NotNull ExplicitReceiverKind explicitReceiverKind
590            ) {
591                logError();
592            }
593    
594            @Override
595            public void unsafeCall(
596                    @NotNull BindingTrace trace, @NotNull KotlinType type, boolean isCallForImplicitInvoke
597            ) {
598                logError();
599            }
600    
601            @Override
602            public void invisibleMember(
603                    @NotNull BindingTrace trace, @NotNull DeclarationDescriptorWithVisibility descriptor
604            ) {
605                logError();
606            }
607    
608            @Override
609            public void typeInferenceFailed(
610                    @NotNull ResolutionContext<?> context, @NotNull InferenceErrorData inferenceErrorData
611            ) {
612                logError();
613            }
614        }
615    }