From 4d5d24a503825e5cbdafd0f7ce27ed14758b77b7 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 11 Nov 2015 19:42:15 +0300 Subject: [PATCH] Minor, move out check against no expected type --- .../org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java | 2 +- .../src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt | 2 +- .../resolve/calls/inference/ConstraintSystemBuilderImpl.kt | 2 -- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java index bcdc03b74d6..fae2ba39e85 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DelegatedPropertyResolver.java @@ -368,7 +368,7 @@ public class DelegatedPropertyResolver { if (conventionMethodFound(getMethodResults)) { FunctionDescriptor descriptor = getMethodResults.getResultingDescriptor(); KotlinType returnTypeOfGetMethod = descriptor.getReturnType(); - if (returnTypeOfGetMethod != null) { + if (returnTypeOfGetMethod != null && !TypeUtils.noExpectedType(expectedType)) { constraintSystem.addSupertypeConstraint(expectedType, returnTypeOfGetMethod, FROM_COMPLETER.position()); } addConstraintForThisValue(constraintSystem, descriptor); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt index 1ea45ad0a85..34d2db08056 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CallCompleter.kt @@ -147,7 +147,7 @@ public class CallCompleter( } val returnType = getCandidateDescriptor().getReturnType() - if (returnType != null) { + if (returnType != null && !TypeUtils.noExpectedType(expectedType)) { updateSystemIfNeeded { builder -> builder.addSupertypeConstraint(expectedType, returnType, EXPECTED_TYPE_POSITION.position()) builder.build() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt index 995a1ce6c34..76bb4b5d29d 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/inference/ConstraintSystemBuilderImpl.kt @@ -102,8 +102,6 @@ class ConstraintSystemBuilderImpl : ConstraintSystem.Builder { type.getNestedTypeParameters().filter { isMyTypeVariable(it) } override fun addSupertypeConstraint(constrainingType: KotlinType?, subjectType: KotlinType, constraintPosition: ConstraintPosition) { - if (constrainingType != null && TypeUtils.noExpectedType(constrainingType)) return - val newSubjectType = descriptorToVariableSubstitutor.substitute(subjectType, Variance.INVARIANT) addConstraint(SUB_TYPE, newSubjectType, constrainingType, ConstraintContext(constraintPosition, initial = true)) }