File tree Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Expand file tree Collapse file tree 4 files changed +13
-22
lines changed Original file line number Diff line number Diff line change @@ -939,7 +939,11 @@ DefineMemberBasedOnUse::diagnoseForAmbiguity(CommonFixesArray commonFixes) const
939939 const auto *solution = solutionAndFix.first ;
940940 const auto *fix = solutionAndFix.second ->getAs <DefineMemberBasedOnUse>();
941941
942- auto baseType = solution->simplifyType (fix->BaseType );
942+ // Ignore differences in optionality since we can look through an optional
943+ // to resolve an implicit member `.foo`.
944+ auto baseType = solution->simplifyType (fix->BaseType )
945+ ->getMetatypeInstanceType ()
946+ ->lookThroughAllOptionalTypes ();
943947 if (!concreteBaseType)
944948 concreteBaseType = baseType;
945949
Original file line number Diff line number Diff line change @@ -11604,22 +11604,11 @@ ConstraintSystem::SolutionKind ConstraintSystem::simplifyMemberConstraint(
1160411604 // `key path` constraint can't be retired until all components
1160511605 // are simplified.
1160611606 addTypeVariableConstraintsToWorkList(memberTypeVar);
11607- } else if (isa<Expr *>(locator->getAnchor()) &&
11608- !getSemanticsProvidingParentExpr(
11609- getAsExpr(locator->getAnchor()))) {
11610- // If there are no contextual expressions that could provide
11611- // a type for the member type variable, let's default it to
11612- // a placeholder eagerly so it could be propagated to the
11613- // pattern if necessary.
11614- recordTypeVariablesAsHoles(memberTypeVar);
11615- } else if (locator->isLastElement<LocatorPathElt::PatternMatch>()) {
11616- // Let's handle member patterns specifically because they use
11617- // equality instead of argument application constraint, so allowing
11618- // them to bind member could mean missing valid hole positions in
11619- // the pattern.
11620- recordTypeVariablesAsHoles(memberTypeVar);
1162111607 } else {
11622- recordPotentialHole(memberTypeVar);
11608+ // Eagerly turn the member type variable into a hole since we know
11609+ // this is where the issue is and we've recorded a fix for it. This
11610+ // avoids producing unnecessary holes for e.g generic parameters.
11611+ recordTypeVariablesAsHoles(memberTypeVar);
1162311612 }
1162411613 }
1162511614
Original file line number Diff line number Diff line change @@ -1362,7 +1362,7 @@ do {
13621362 }
13631363 }
13641364
1365- test { // expected-error {{invalid conversion from throwing function of type '(Int) throws -> Void ' to non-throwing function type '(Int) -> Void'}}
1365+ test { // expected-error {{invalid conversion from throwing function of type '(Int) throws -> _ ' to non-throwing function type '(Int) -> Void'}}
13661366 try $0. missing // expected-error {{value of type 'Int' has no member 'missing'}}
13671367 }
13681368}
Original file line number Diff line number Diff line change @@ -196,11 +196,9 @@ takesP1AndP2([DoesNotExist & P1 & P2]()) // expected-error {{cannot find 'DoesNo
196196// expected-error@-2 {{binary operator '&' cannot be applied to operands of type 'UInt8' and '(any P1).Type'}}
197197// expected-note@-3 2 {{overloads for '&' exist with these partially matching parameter lists}}
198198// expected-error@-4 {{cannot call value of non-function type '[UInt8]'}}
199- takesP1AndP2 ( [ Swift . DoesNotExist & P1 & P2] ( ) ) // expected-error {{module 'Swift' has no member named 'DoesNotExist'}}
200- // expected-error@-1 {{binary operator '&' cannot be applied to operands of type 'UInt8' and '(any P2).Type'}}
201- // expected-error@-2 {{binary operator '&' cannot be applied to operands of type 'UInt8' and '(any P1).Type'}}
202- // expected-note@-3 2 {{overloads for '&' exist with these partially matching parameter lists}}
203- // expected-error@-4 {{cannot call value of non-function type '[UInt8]'}}
199+ takesP1AndP2 ( [ Swift . DoesNotExist & P1 & P2] ( ) )
200+ // expected-error@-1 {{module 'Swift' has no member named 'DoesNotExist'}}
201+ // expected-error@-2 {{cannot call value of non-function type '[Element]'}}
204202
205203typealias T08 = P1 & inout P2 // expected-error {{'inout' may only be used on parameters}}
206204typealias T09 = P1 & __shared P2 // expected-error {{'__shared' may only be used on parameters}}
You can’t perform that action at this time.
0 commit comments