Merge pull request #26302 from xedin/remove-label-mismatch-from-lookup

[Diagnostics] Don't filter overload set candidates based on labels in lookup
This commit is contained in:
Pavel Yaskevich
2019-07-26 10:34:23 -07:00
committed by GitHub
21 changed files with 209 additions and 166 deletions

View File

@@ -1493,10 +1493,18 @@ Type ConstraintSystem::getEffectiveOverloadType(const OverloadChoice &overload,
return Type();
if (!overload.getBaseType()->getOptionalObjectType()) {
Type selfType = overload.getBaseType()->getRValueType()
->getMetatypeInstanceType()
->lookThroughAllOptionalTypes();
type = type->replaceCovariantResultType(selfType, 2);
Type selfType = overload.getBaseType()
->getRValueType()
->getMetatypeInstanceType();
// `Int??(0)` if we look through all optional types for `Self`
// we'll end up with incorrect type `Int?` for result because
// the actual result type is `Int??`.
if (isa<ConstructorDecl>(decl) && selfType->getOptionalObjectType())
return Type();
type = type->replaceCovariantResultType(
selfType->lookThroughAllOptionalTypes(), 2);
}
}
}