File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -3484,6 +3484,15 @@ class ConstraintSystem {
3484
3484
return nullptr ;
3485
3485
}
3486
3486
3487
+ Expr *getSemanticsProvidingParentExpr (Expr *expr) {
3488
+ while (auto *parent = getParentExpr (expr)) {
3489
+ if (parent->getSemanticsProvidingExpr () == parent)
3490
+ return parent;
3491
+ expr = parent;
3492
+ }
3493
+ return nullptr ;
3494
+ }
3495
+
3487
3496
// / Retrieve the depth of the given expression.
3488
3497
std::optional<unsigned > getExprDepth (Expr *expr) {
3489
3498
if (auto result = getExprDepthAndParent (expr))
Original file line number Diff line number Diff line change @@ -11438,6 +11438,14 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
11438
11438
// `key path` constraint can't be retired until all components
11439
11439
// are simplified.
11440
11440
addTypeVariableConstraintsToWorkList(memberTypeVar);
11441
+ } else if (locator->getAnchor().is<Expr *>() &&
11442
+ !getSemanticsProvidingParentExpr(
11443
+ getAsExpr(locator->getAnchor()))) {
11444
+ // If there are no contextual expressions that could provide
11445
+ // a type for the member type variable, let's default it to
11446
+ // a placeholder eagerly so it could be propagated to the
11447
+ // pattern if necessary.
11448
+ recordTypeVariablesAsHoles(memberTypeVar);
11441
11449
} else if (locator->isLastElement<LocatorPathElt::PatternMatch>()) {
11442
11450
// Let's handle member patterns specifically because they use
11443
11451
// equality instead of argument application constraint, so allowing
Original file line number Diff line number Diff line change @@ -803,7 +803,6 @@ overloaded { print("hi"); print("bye") } // multiple expression closure without
803
803
// expected-error@-1 {{ambiguous use of 'overloaded'}}
804
804
805
805
func not_overloaded( _ handler: ( ) -> Int ) { }
806
- // expected-note@-1 {{'not_overloaded' declared here}}
807
806
808
807
not_overloaded { } // empty body
809
808
// expected-error@-1 {{cannot convert value of type '()' to closure result type 'Int'}}
@@ -1347,3 +1346,23 @@ do {
1347
1346
let _ = V ( value: { [ Int] ( ) } ) // expected-error {{add () to forward '@autoclosure' parameter}} {{31-31=()}}
1348
1347
let _ = V ( other: { [ Int] ( ) } ) // expected-error {{cannot convert value of type '[Int]' to closure result type 'String'}}
1349
1348
}
1349
+
1350
+ // https://github.com/swiftlang/swift/issues/81770
1351
+ do {
1352
+ func test( _: Int ) { }
1353
+ func test( _: Int = 42 , _: ( Int ) -> Void ) { }
1354
+
1355
+ test {
1356
+ if let _ = $0. missing { // expected-error {{value of type 'Int' has no member 'missing'}}
1357
+ }
1358
+ }
1359
+
1360
+ test {
1361
+ if let _ = ( ( $0. missing) ) { // expected-error {{value of type 'Int' has no member 'missing'}}
1362
+ }
1363
+ }
1364
+
1365
+ test { // expected-error {{invalid conversion from throwing function of type '(Int) throws -> Void' to non-throwing function type '(Int) -> Void'}}
1366
+ try $0. missing // expected-error {{value of type 'Int' has no member 'missing'}}
1367
+ }
1368
+ }
You can’t perform that action at this time.
0 commit comments