001 /* 002 * Copyright 2010-2016 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.resolve.calls.context; 018 019 import org.jetbrains.annotations.NotNull; 020 import org.jetbrains.annotations.Nullable; 021 import org.jetbrains.kotlin.psi.Call; 022 import org.jetbrains.kotlin.resolve.BindingTrace; 023 import org.jetbrains.kotlin.resolve.StatementFilter; 024 import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl; 025 import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments; 026 import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; 027 import org.jetbrains.kotlin.resolve.scopes.LexicalScope; 028 import org.jetbrains.kotlin.types.KotlinType; 029 030 public abstract class CallResolutionContext<Context extends CallResolutionContext<Context>> extends ResolutionContext<Context> { 031 @NotNull 032 public final Call call; 033 @NotNull 034 public final CheckArgumentTypesMode checkArguments; 035 @NotNull 036 public final MutableDataFlowInfoForArguments dataFlowInfoForArguments; 037 038 protected CallResolutionContext( 039 @NotNull BindingTrace trace, 040 @NotNull LexicalScope scope, 041 @NotNull Call call, 042 @NotNull KotlinType expectedType, 043 @NotNull DataFlowInfo dataFlowInfo, 044 @NotNull ContextDependency contextDependency, 045 @NotNull CheckArgumentTypesMode checkArguments, 046 @NotNull ResolutionResultsCache resolutionResultsCache, 047 @SuppressWarnings("NullableProblems") 048 @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments, 049 @NotNull StatementFilter statementFilter, 050 boolean isAnnotationContext, 051 boolean isDebuggerContext, 052 boolean collectAllCandidates, 053 @NotNull CallPosition callPosition 054 ) { 055 super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache, 056 statementFilter, isAnnotationContext, isDebuggerContext, collectAllCandidates, callPosition); 057 this.call = call; 058 this.checkArguments = checkArguments; 059 if (dataFlowInfoForArguments != null) { 060 this.dataFlowInfoForArguments = dataFlowInfoForArguments; 061 } 062 else if (checkArguments == CheckArgumentTypesMode.CHECK_VALUE_ARGUMENTS) { 063 this.dataFlowInfoForArguments = new DataFlowInfoForArgumentsImpl(dataFlowInfo, call); 064 } 065 else { 066 this.dataFlowInfoForArguments = new MutableDataFlowInfoForArguments.WithoutArgumentsCheck(dataFlowInfo); 067 } 068 } 069 }