[NI] Fix KnownTypeParameterSubstitutor for !!

This commit is contained in:
Dmitry Savvinov
2017-11-30 20:05:42 +03:00
parent 15a595749b
commit 1ada52968b
3 changed files with 8 additions and 4 deletions
@@ -26,6 +26,8 @@ import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.KotlinBuiltIns;
import org.jetbrains.kotlin.config.LanguageFeature;
import org.jetbrains.kotlin.config.LanguageVersionSettings;
import org.jetbrains.kotlin.descriptors.*;
import org.jetbrains.kotlin.descriptors.annotations.Annotations;
import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
@@ -116,7 +118,7 @@ public class ControlStructureTypingUtils {
SimpleFunctionDescriptorImpl function = createFunctionDescriptorForSpecialConstruction(
construct, argumentNames, isArgumentNullable);
TracingStrategy tracing = createTracingForSpecialConstruction(call, construct.getName(), context);
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType);
TypeSubstitutor knownTypeParameterSubstitutor = createKnownTypeParameterSubstitutorForSpecialCall(construct, function, context.expectedType, context.languageVersionSettings);
ResolutionCandidate<FunctionDescriptor> resolutionCandidate =
ResolutionCandidate.create(call, function, knownTypeParameterSubstitutor);
OverloadResolutionResults<FunctionDescriptor> results = callResolver.resolveCallWithKnownCandidate(
@@ -128,9 +130,11 @@ public class ControlStructureTypingUtils {
private static @Nullable TypeSubstitutor createKnownTypeParameterSubstitutorForSpecialCall(
@NotNull ResolveConstruct construct,
@NotNull SimpleFunctionDescriptorImpl function,
@NotNull KotlinType expectedType
@NotNull KotlinType expectedType,
@NotNull LanguageVersionSettings languageVersionSettings
) {
if (construct == ResolveConstruct.ELVIS
|| construct == ResolveConstruct.EXCL_EXCL
|| TypeUtils.noExpectedType(expectedType)
|| TypeUtils.isDontCarePlaceholder(expectedType)
|| KotlinBuiltIns.isUnitOrNullableUnit(expectedType)
@@ -34,6 +34,6 @@ fun main(args : Array<String>) {
}
}
val <!UNUSED_VARIABLE!>f<!> : String = <!TYPE_MISMATCH!>a<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>
val <!UNUSED_VARIABLE!>f<!> : String = <!NI;TYPE_MISMATCH!><!OI;TYPE_MISMATCH!>a<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!><!>
checkSubtype<String>(<!NI;TYPE_MISMATCH, NI;TYPE_MISMATCH!><!OI;TYPE_MISMATCH!>a<!><!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!><!>)
}
@@ -3,7 +3,7 @@ fun main(args : Array<String>) {
val a : Int? = null;
var v = 1
val <!UNUSED_VARIABLE!>b<!> : String = <!NI;TYPE_MISMATCH, TYPE_MISMATCH!>v<!>;
val <!UNUSED_VARIABLE!>f<!> : String = <!TYPE_MISMATCH!>a<!>!!;
val <!UNUSED_VARIABLE!>f<!> : String = <!NI;TYPE_MISMATCH!><!OI;TYPE_MISMATCH!>a<!>!!<!>;
val <!UNUSED_VARIABLE!>g<!> : String = <!TYPE_MISMATCH!>v++<!>;
val <!UNUSED_VARIABLE!>g1<!> : String = <!TYPE_MISMATCH!>++v<!>;
val <!UNUSED_VARIABLE!>h<!> : String = <!TYPE_MISMATCH!>v--<!>;