Skip to content

Commit f702e46

Browse files
authored
Merge pull request #77475 from slavapestov/fix-rdar139237781
Sema: Fix handling of appliedPropertyWrappers in ConstraintSystem::replaySolution()
2 parents 9cc59e1 + d67e89d commit f702e46

File tree

5 files changed

+40
-5
lines changed

5 files changed

+40
-5
lines changed

lib/AST/NameLookup.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -3812,7 +3812,7 @@ CustomAttrNominalRequest::evaluate(Evaluator &evaluator,
38123812
directReferencesForTypeRepr(evaluator, ctx, typeRepr, dc,
38133813
defaultDirectlyReferencedTypeLookupOptions);
38143814
} else if (Type type = attr->getType()) {
3815-
decls = directReferencesForType(type);
3815+
return type->getAnyNominal();
38163816
}
38173817

38183818
// Dig out the nominal type declarations.

lib/Sema/CSApply.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6403,6 +6403,8 @@ ArgumentList *ExprRewriter::coerceCallArguments(
64036403
arg.setExpr(convertedArg);
64046404
newArgs.push_back(arg);
64056405
}
6406+
6407+
ASSERT(appliedWrapperIndex == appliedPropertyWrappers.size());
64066408
return ArgumentList::createTypeChecked(ctx, args, newArgs);
64076409
}
64086410

lib/Sema/CSGen.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -5045,6 +5045,10 @@ void ConstraintSystem::removePropertyWrapper(Expr *anchor) {
50455045
auto &wrappers = found->second;
50465046
ASSERT(!wrappers.empty());
50475047
wrappers.pop_back();
5048+
if (wrappers.empty()) {
5049+
bool erased = appliedPropertyWrappers.erase(anchor);
5050+
ASSERT(erased);
5051+
}
50485052
}
50495053

50505054
ConstraintSystem::TypeMatchResult

lib/Sema/CSSolver.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,10 @@ void ConstraintSystem::replaySolution(const Solution &solution,
431431
for (const auto &appliedWrapper : solution.appliedPropertyWrappers) {
432432
auto found = appliedPropertyWrappers.find(appliedWrapper.first);
433433
if (found == appliedPropertyWrappers.end()) {
434-
appliedPropertyWrappers.insert(appliedWrapper);
434+
for (auto applied : appliedWrapper.second)
435+
applyPropertyWrapper(getAsExpr(appliedWrapper.first), applied);
435436
} else {
436-
auto &existing = found->second;
437-
ASSERT(existing.size() <= appliedWrapper.second.size());
438-
existing = appliedWrapper.second;
437+
ASSERT(found->second.size() == appliedWrapper.second.size());
439438
}
440439
}
441440

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %target-typecheck-verify-swift -target %target-cpu-apple-macosx12
2+
3+
// REQUIRES: objc_interop
4+
// REQUIRES: OS=macosx
5+
6+
import SwiftUI
7+
8+
struct V: View {
9+
struct M: Identifiable {
10+
let id: String
11+
}
12+
13+
class C: ObservableObject {
14+
@Published var m: [M]
15+
16+
init() {
17+
self.m = []
18+
}
19+
}
20+
21+
@ObservedObject var c: C
22+
23+
var body: some View {
24+
Table($c.m) {
25+
TableColumn("") { $entry in
26+
Text("hi")
27+
}
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)