001 /* 002 * Copyright 2010-2015 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.checkers.AdditionalTypeChecker; 025 import org.jetbrains.kotlin.resolve.calls.checkers.CallChecker; 026 import org.jetbrains.kotlin.resolve.calls.model.DataFlowInfoForArgumentsImpl; 027 import org.jetbrains.kotlin.resolve.calls.model.MutableDataFlowInfoForArguments; 028 import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo; 029 import org.jetbrains.kotlin.resolve.scopes.JetScope; 030 import org.jetbrains.kotlin.resolve.validation.SymbolUsageValidator; 031 import org.jetbrains.kotlin.types.JetType; 032 033 public abstract class CallResolutionContext<Context extends CallResolutionContext<Context>> extends ResolutionContext<Context> { 034 @NotNull 035 public final Call call; 036 @NotNull 037 public final CheckValueArgumentsMode checkArguments; 038 @NotNull 039 public final MutableDataFlowInfoForArguments dataFlowInfoForArguments; 040 041 protected CallResolutionContext( 042 @NotNull BindingTrace trace, 043 @NotNull JetScope scope, 044 @NotNull Call call, 045 @NotNull JetType expectedType, 046 @NotNull DataFlowInfo dataFlowInfo, 047 @NotNull ContextDependency contextDependency, 048 @NotNull CheckValueArgumentsMode checkArguments, 049 @NotNull ResolutionResultsCache resolutionResultsCache, 050 @SuppressWarnings("NullableProblems") 051 @Nullable MutableDataFlowInfoForArguments dataFlowInfoForArguments, 052 @NotNull CallChecker callChecker, 053 SymbolUsageValidator symbolUsageValidator, 054 @NotNull AdditionalTypeChecker additionalTypeChecker, 055 @NotNull StatementFilter statementFilter, 056 boolean isAnnotationContext, 057 boolean collectAllCandidates, 058 boolean insideSafeCallChain 059 ) { 060 super(trace, scope, expectedType, dataFlowInfo, contextDependency, resolutionResultsCache, callChecker, symbolUsageValidator, 061 additionalTypeChecker, 062 statementFilter, isAnnotationContext, collectAllCandidates, insideSafeCallChain); 063 this.call = call; 064 this.checkArguments = checkArguments; 065 if (dataFlowInfoForArguments != null) { 066 this.dataFlowInfoForArguments = dataFlowInfoForArguments; 067 } 068 else if (checkArguments == CheckValueArgumentsMode.ENABLED) { 069 this.dataFlowInfoForArguments = new DataFlowInfoForArgumentsImpl(call); 070 } 071 else { 072 this.dataFlowInfoForArguments = new MutableDataFlowInfoForArguments.WithoutArgumentsCheck(); 073 } 074 } 075 076 @NotNull 077 public BasicCallResolutionContext toBasic() { 078 return BasicCallResolutionContext.create(this, call, checkArguments); 079 } 080 }