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 {
34843484 return nullptr ;
34853485 }
34863486
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+
34873496 // / Retrieve the depth of the given expression.
34883497 std::optional<unsigned > getExprDepth (Expr *expr) {
34893498 if (auto result = getExprDepthAndParent (expr))
Original file line number Diff line number Diff line change @@ -11438,6 +11438,14 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
1143811438 // `key path` constraint can't be retired until all components
1143911439 // are simplified.
1144011440 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);
1144111449 } else if (locator->isLastElement<LocatorPathElt::PatternMatch>()) {
1144211450 // Let's handle member patterns specifically because they use
1144311451 // 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
803803// expected-error@-1 {{ambiguous use of 'overloaded'}}
804804
805805func not_overloaded( _ handler: ( ) -> Int ) { }
806- // expected-note@-1 {{'not_overloaded' declared here}}
807806
808807not_overloaded { } // empty body
809808// expected-error@-1 {{cannot convert value of type '()' to closure result type 'Int'}}
@@ -1347,3 +1346,23 @@ do {
13471346 let _ = V ( value: { [ Int] ( ) } ) // expected-error {{add () to forward '@autoclosure' parameter}} {{31-31=()}}
13481347 let _ = V ( other: { [ Int] ( ) } ) // expected-error {{cannot convert value of type '[Int]' to closure result type 'String'}}
13491348}
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