Skip to content

Commit eeab483

Browse files
committed
Sema: Undo changes in chronological order in SolverTrail::undo()
1 parent 1a60685 commit eeab483

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

lib/Sema/CSTrail.cpp

+2-13
Original file line numberDiff line numberDiff line change
@@ -730,21 +730,10 @@ void SolverTrail::undo(unsigned toIndex) {
730730
ASSERT(!UndoActive);
731731
UndoActive = true;
732732

733-
// FIXME: Undo all changes in the correct order!
734733
for (unsigned i = Changes.size(); i > toIndex; i--) {
735734
auto change = Changes[i - 1];
736-
if (change.Kind == ChangeKind::UpdatedTypeVariable) {
737-
LLVM_DEBUG(llvm::dbgs() << "- "; change.dump(llvm::dbgs(), CS, 0));
738-
change.undo(CS);
739-
}
740-
}
741-
742-
for (unsigned i = Changes.size(); i > toIndex; i--) {
743-
auto change = Changes[i - 1];
744-
if (change.Kind != ChangeKind::UpdatedTypeVariable) {
745-
LLVM_DEBUG(llvm::dbgs() << "- "; change.dump(llvm::dbgs(), CS, 0));
746-
change.undo(CS);
747-
}
735+
LLVM_DEBUG(llvm::dbgs() << "- "; change.dump(llvm::dbgs(), CS, 0));
736+
change.undo(CS);
748737
}
749738

750739
Changes.resize(toIndex);

test/Sema/issue-46000.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ struct Data {}
1111
extension DispatchData {
1212
func asFoundationData<T>(execute: (Data) throws -> T) rethrows -> T {
1313
return try withUnsafeBytes { (ptr: UnsafePointer<Int8>) -> Void in
14-
// expected-error@-1 {{cannot convert return expression of type 'Void' to return type 'T'}}
14+
// expected-error@-1 {{declared closure result 'Void' is incompatible with contextual type 'T'}}
1515
let data = Data()
1616
return try execute(data) // expected-error {{cannot convert value of type 'T' to closure result type 'Void'}}
1717
}

test/type/opaque.swift

+1-4
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,8 @@ func associatedTypeIdentity() {
273273
sameType(cr, dr) // expected-error {{conflicting arguments to generic parameter 'T' ('(some R).S' (result type of 'candace') vs. '(some R).S' (result type of 'doug'))}}
274274
sameType(gary(candace()).r_out(), gary(candace()).r_out())
275275
sameType(gary(doug()).r_out(), gary(doug()).r_out())
276-
// TODO(diagnostics): This is not great but the problem comes from the way solver discovers and attempts bindings, if we could detect that
277-
// `(some R).S` from first reference to `gary()` in inconsistent with the second one based on the parent type of `S` it would be much easier to diagnose.
278276
sameType(gary(doug()).r_out(), gary(candace()).r_out())
279-
// expected-error@-1:12 {{conflicting arguments to generic parameter 'T' ('some R' (result type of 'doug') vs. 'some R' (result type of 'candace'))}}
280-
// expected-error@-2:34 {{conflicting arguments to generic parameter 'T' ('some R' (result type of 'doug') vs. 'some R' (result type of 'candace'))}}
277+
// expected-error@-1:39 {{cannot convert value of type 'some R' (result of 'candace()') to expected argument type 'some R' (result of 'doug()')}}
281278
}
282279

283280
func redeclaration() -> some P { return 0 } // expected-note 2{{previously declared}}

0 commit comments

Comments
 (0)