Minor, move out check against no expected type

This commit is contained in:
Alexander Udalov
2015-11-11 19:42:15 +03:00
parent e50eb50299
commit 4d5d24a503
3 changed files with 2 additions and 4 deletions
@@ -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);
@@ -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()
@@ -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))
}