Revert "[Sema] Improve diagnostics for witness mismatches against @objc protocols." and "Improve diagnostics for selector collisions with @objc optional requirements."

This reverts commits 46269299cd
and 27279866ad
and c826a408dd.

The changes broke test bots, including
https://ci.swift.org/job/oss-swift-package-osx/1348/
This commit is contained in:
Greg Parker
2016-04-19 05:51:23 -07:00
parent 4f98a54eb4
commit 125a146365
19 changed files with 217 additions and 602 deletions

View File

@@ -1039,16 +1039,6 @@ Type ConstraintSystem::replaceSelfTypeInArchetype(ArchetypeType *archetype) {
return archetype;
}
/// Determine whether the given locator is for a witness or requirement.
static bool isRequirementOrWitnesss(const ConstraintLocatorBuilder &locator) {
if (auto last = locator.last()) {
return last->getKind() == ConstraintLocator::Requirement ||
last->getKind() == ConstraintLocator::Witness;
}
return false;
}
std::pair<Type, Type>
ConstraintSystem::getTypeOfMemberReference(
Type baseTy, ValueDecl *value,
@@ -1247,14 +1237,10 @@ ConstraintSystem::getTypeOfMemberReference(
// optional/dynamic, is settable, or is not.
auto fnType = openedFnType->getResult()->castTo<FunctionType>();
auto elementTy = fnType->getResult();
if (!isRequirementOrWitnesss(locator)) {
if (subscript->getAttrs().hasAttribute<OptionalAttr>())
elementTy = OptionalType::get(elementTy->getRValueType());
else if (isDynamicResult) {
elementTy = ImplicitlyUnwrappedOptionalType::get(
elementTy->getRValueType());
}
}
if (subscript->getAttrs().hasAttribute<OptionalAttr>())
elementTy = OptionalType::get(elementTy->getRValueType());
else if (isDynamicResult)
elementTy = ImplicitlyUnwrappedOptionalType::get(elementTy->getRValueType());
type = FunctionType::get(fnType->getInput(), elementTy);
} else if (isa<ProtocolDecl>(value->getDeclContext()) &&
@@ -1386,9 +1372,8 @@ void ConstraintSystem::resolveOverload(ConstraintLocator *locator,
= getTypeOfReference(choice.getDecl(), isTypeReference,
choice.isSpecialized(), locator);
}
if (!isRequirementOrWitnesss(locator) &&
choice.getDecl()->getAttrs().hasAttribute<OptionalAttr>() &&
if (choice.getDecl()->getAttrs().hasAttribute<OptionalAttr>() &&
!isa<SubscriptDecl>(choice.getDecl())) {
// For a non-subscript declaration that is an optional
// requirement in a protocol, strip off the lvalue-ness (FIXME: