Skip to content

Commit 39b2ff9

Browse files
committed
[CSStep] Skip disabled overloads only if there are no fixes in diagnostic mode
1 parent cd08350 commit 39b2ff9

File tree

4 files changed

+8
-10
lines changed

4 files changed

+8
-10
lines changed

lib/Sema/CSStep.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,6 @@ bool TypeChecker::isDeclRefinementOf(ValueDecl *declA, ValueDecl *declB) {
598598
bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
599599
auto &ctx = CS.getASTContext();
600600

601-
// Never skip disjunction choices in diagnostic mode.
602-
if (CS.shouldAttemptFixes())
603-
return false;
604-
605601
auto skip = [&](std::string reason) -> bool {
606602
if (CS.isDebugMode()) {
607603
auto &log = getDebugLogger();
@@ -613,11 +609,14 @@ bool DisjunctionStep::shouldSkip(const DisjunctionChoice &choice) const {
613609
return true;
614610
};
615611

616-
if (choice.isDisabled())
612+
613+
// Skip disabled overloads in the diagnostic mode if they do not have a
614+
// fix attached to them e.g. overloads where labels didn't match up.
615+
if (choice.isDisabled() && !(CS.shouldAttemptFixes() && choice.hasFix()))
617616
return skip("disabled");
618617

619-
// Skip unavailable overloads.
620-
if (choice.isUnavailable())
618+
// Skip unavailable overloads (unless in dignostic mode).
619+
if (choice.isUnavailable() && !CS.shouldAttemptFixes())
621620
return skip("unavailable");
622621

623622
if (ctx.TypeCheckerOpts.DisableConstraintSolverPerformanceHacks)

test/Constraints/generics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ let arr = [BottleLayout]()
648648
let layout = BottleLayout(count:1)
649649
let ix = arr.firstIndex(of:layout) // expected-error {{referencing instance method 'firstIndex(of:)' on 'Collection' requires that 'BottleLayout' conform to 'Equatable'}}
650650

651-
let _: () -> UInt8 = { .init("a" as Unicode.Scalar) } // expected-error {{missing argument label 'ascii:' in call}}
651+
let _: () -> UInt8 = { .init("a" as Unicode.Scalar) } // expected-error {{initializer 'init(_:)' requires that 'Unicode.Scalar' conform to 'BinaryInteger'}}
652652

653653
// https://bugs.swift.org/browse/SR-9068
654654
func compare<C: Collection, Key: Hashable, Value: Equatable>(c: C)

test/stdlib/UnsafePointerDiagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func unsafeRawBufferPointerConversions(
113113
_ = UnsafeRawBufferPointer(start: rp, count: 1)
114114
_ = UnsafeMutableRawBufferPointer(mrbp)
115115
_ = UnsafeRawBufferPointer(mrbp)
116-
_ = UnsafeMutableRawBufferPointer(rbp) // expected-error {{missing argument label 'mutating:' in call}}
116+
_ = UnsafeMutableRawBufferPointer(rbp) // expected-error {{cannot convert value of type 'UnsafeRawBufferPointer' to expected argument type 'UnsafeMutableRawBufferPointer'}}
117117
_ = UnsafeRawBufferPointer(rbp)
118118
_ = UnsafeMutableRawBufferPointer(mbpi)
119119
_ = UnsafeRawBufferPointer(mbpi)

validation-test/Sema/type_checker_crashers_fixed/rdar45470505.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ extension BinaryInteger {
44
init(bytes: [UInt8]) { fatalError() }
55

66
init<S: Sequence>(bytes: S) where S.Iterator.Element == UInt8 {
7-
// expected-note@-1 {{incorrect labels for candidate (have: '(_:)', expected: '(bytes:)')}}
87
self.init(bytes // expected-error {{no exact matches in call to initializer}}
98
// expected-note@-1 {{}}
109

0 commit comments

Comments
 (0)