Skip to content

Commit 1036eff

Browse files
committed
---
yaml --- r: 326015 b: refs/heads/master-next c: 015129c h: refs/heads/master i: 326013: eb044de 326011: c8df921 326007: 87cd363 325999: f70de4b 325983: d7be5ba 325951: f71c509 325887: c35e19d
1 parent 3ff3154 commit 1036eff

File tree

4 files changed

+18
-26
lines changed

4 files changed

+18
-26
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: e052da7d8886fa0439677852e8f7830b20c2e1da
3-
refs/heads/master-next: 078c2b6f455f08d9f18fd5a31a9a9798d8e52870
3+
refs/heads/master-next: 015129cb36ece9b8830f5760d2d557415ea6b86e
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/Sema/CSDiagnostics.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,6 @@ bool RequirementFailure::isStaticOrInstanceMember(const ValueDecl *decl) {
455455
}
456456

457457
bool RequirementFailure::diagnoseAsError() {
458-
if (!canDiagnoseFailure())
459-
return false;
460-
461458
auto *anchor = getRawAnchor();
462459
const auto *reqDC = getRequirementDC();
463460
auto *genericCtx = getGenericContext();
@@ -532,9 +529,6 @@ void RequirementFailure::emitRequirementNote(const Decl *anchor, Type lhs,
532529
}
533530

534531
bool MissingConformanceFailure::diagnoseAsError() {
535-
if (!canDiagnoseFailure())
536-
return false;
537-
538532
auto *anchor = getAnchor();
539533
auto ownerType = getOwnerType();
540534
auto nonConformingType = getLHS();

branches/master-next/lib/Sema/CSDiagnostics.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -285,24 +285,6 @@ class RequirementFailure : public FailureDiagnostic {
285285
virtual DiagInReference getDiagnosticInRereference() const = 0;
286286
virtual DiagAsNote getDiagnosticAsNote() const = 0;
287287

288-
/// Determine whether it would be possible to diagnose
289-
/// current requirement failure.
290-
bool canDiagnoseFailure() const {
291-
// If this is a conditional requirement failure,
292-
// we have a lot more information compared to
293-
// type requirement case, because we know that
294-
// underlying conformance requirement matched.
295-
if (isConditional())
296-
return true;
297-
298-
// For static/initializer calls there is going to be
299-
// a separate fix, attached to the argument, which is
300-
// much easier to diagnose.
301-
// For operator calls we can't currently produce a good
302-
// diagnostic, so instead let's refer to expression diagnostics.
303-
return !(Apply && isOperator(Apply));
304-
}
305-
306288
static bool isOperator(const ApplyExpr *apply) {
307289
return isa<PrefixUnaryExpr>(apply) || isa<PostfixUnaryExpr>(apply) ||
308290
isa<BinaryExpr>(apply);

branches/master-next/lib/Sema/CSSimplify.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,8 +1775,24 @@ ConstraintSystem::matchExistentialTypes(Type type1, Type type2,
17751775
if (auto layoutConstraint = layout.getLayoutConstraint()) {
17761776
if (layoutConstraint->isClass()) {
17771777
if (kind == ConstraintKind::ConformsTo) {
1778-
if (!type1->satisfiesClassConstraint())
1778+
if (!type1->satisfiesClassConstraint()) {
1779+
if (shouldAttemptFixes()) {
1780+
if (auto last = locator.last()) {
1781+
// If solver is in diagnostic mode and this is a
1782+
// superclass requirement, let's consider conformance
1783+
// to `AnyObject` as solved since actual superclass
1784+
// requirement is going to fail too (because type can't
1785+
// satisfy it), and it's more interesting from diagnostics
1786+
// perspective.
1787+
auto req = last->getAs<LocatorPathElt::AnyRequirement>();
1788+
if (req &&
1789+
req->getRequirementKind() == RequirementKind::Superclass)
1790+
return getTypeMatchSuccess();
1791+
}
1792+
}
1793+
17791794
return getTypeMatchFailure(locator);
1795+
}
17801796
} else {
17811797
// Subtype relation to AnyObject also allows class-bound
17821798
// existentials that are not @objc and therefore carry

0 commit comments

Comments
 (0)