mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Revert "[Sema] Improve diagnostics for witness mismatches against @objc protocols." and "Improve diagnostics for selector collisions with @objc optional requirements."
This reverts commits46269299cdand27279866adandc826a408dd. The changes broke test bots, including https://ci.swift.org/job/oss-swift-package-osx/1348/
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user