Skip to content

Commit b6afd21

Browse files
committed
Merge remote-tracking branch 'origin/main' into rebranch
2 parents 6fb243f + 35a0dab commit b6afd21

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

include/swift/Sema/ConstraintSystem.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,9 +1735,9 @@ class SolutionApplicationTarget {
17351735
}
17361736

17371737
static SolutionApplicationTarget
1738-
forUninitializedVar(PatternBindingDecl *binding, unsigned index, Pattern *var,
1738+
forUninitializedVar(PatternBindingDecl *binding, unsigned index,
17391739
Type patternTy) {
1740-
return {binding, index, var, patternTy};
1740+
return {binding, index, binding->getPattern(index), patternTy};
17411741
}
17421742

17431743
/// Form a target for a synthesized property wrapper initializer.

lib/Sema/CSGen.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3926,10 +3926,13 @@ bool ConstraintSystem::generateConstraints(
39263926
if (!pattern)
39273927
return true;
39283928

3929-
// Type check the pattern. Note use of `forRawPattern` here instead
3930-
// of `forPatternBindingDecl` because resolved `pattern` is not
3931-
// associated with `patternBinding`.
3932-
auto contextualPattern = ContextualPattern::forRawPattern(pattern, dc);
3929+
// Reset binding to point to the resolved pattern. This is required
3930+
// before calling `forPatternBindingDecl`.
3931+
patternBinding->setPattern(index, pattern,
3932+
patternBinding->getInitContext(index));
3933+
3934+
auto contextualPattern =
3935+
ContextualPattern::forPatternBindingDecl(patternBinding, index);
39333936
Type patternType = TypeChecker::typeCheckPattern(contextualPattern);
39343937

39353938
// Fail early if pattern couldn't be type-checked.
@@ -3944,10 +3947,10 @@ bool ConstraintSystem::generateConstraints(
39443947

39453948
auto init = patternBinding->getInit(index);
39463949
auto target = init ? SolutionApplicationTarget::forInitialization(
3947-
init, dc, patternType, pattern,
3950+
init, dc, patternType, patternBinding, index,
39483951
/*bindPatternVarsOneWay=*/true)
39493952
: SolutionApplicationTarget::forUninitializedVar(
3950-
patternBinding, index, pattern, patternType);
3953+
patternBinding, index, patternType);
39513954

39523955
if (generateConstraints(target, FreeTypeVariableBinding::Disallow)) {
39533956
hadError = true;

validation-test/Sema/type_checker_crashers_fixed/sr14893.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct Image : View {
2323

2424
struct MyView {
2525
@ViewBuilder var body: some View {
26-
let icon: Category! = Category.first // expected-error {{using '!' is not allowed here; perhaps '?' was intended?}} {{23-24=?}}
26+
let icon: Category! = Category.first // Ok
2727
Image().test(icon)
2828
}
2929
}

0 commit comments

Comments
 (0)