@@ -60,7 +60,7 @@ void PostfixCompletionCallback::sawSolutionImpl(
60
60
auto *Locator = CS.getConstraintLocator (SemanticExpr);
61
61
Type ExpectedTy = getTypeForCompletion (S, CompletionExpr);
62
62
Expr *ParentExpr = CS.getParentExpr (CompletionExpr);
63
- if (!ParentExpr)
63
+ if (!ParentExpr && !ExpectedTy )
64
64
ExpectedTy = CS.getContextualType (CompletionExpr, /* forConstraint=*/ false );
65
65
66
66
auto *CalleeLocator = S.getCalleeLocator (Locator);
@@ -75,10 +75,19 @@ void PostfixCompletionCallback::sawSolutionImpl(
75
75
if (Ret.second ) {
76
76
bool ISDMT = S.isStaticallyDerivedMetatype (ParsedExpr);
77
77
bool ImplicitReturn = isImplicitSingleExpressionReturn (CS, CompletionExpr);
78
- bool DisallowVoid = ExpectedTy
79
- ? !ExpectedTy->isVoid ()
80
- : !ParentExpr && CS.getContextualTypePurpose (
81
- CompletionExpr) != CTP_Unused;
78
+ bool DisallowVoid = false ;
79
+ DisallowVoid |= ExpectedTy && !ExpectedTy->isVoid ();
80
+ DisallowVoid |= !ParentExpr &&
81
+ CS.getContextualTypePurpose (CompletionExpr) != CTP_Unused;
82
+ for (auto SAT : S.solutionApplicationTargets ) {
83
+ if (DisallowVoid) {
84
+ // DisallowVoid is already set. No need to iterate further.
85
+ break ;
86
+ }
87
+ if (SAT.second .getAsExpr () == CompletionExpr) {
88
+ DisallowVoid |= SAT.second .getExprContextualTypePurpose () != CTP_Unused;
89
+ }
90
+ }
82
91
83
92
Results.push_back ({BaseTy, ReferencedDecl,
84
93
/* ExpectedTypes=*/ {}, DisallowVoid, ISDMT,
0 commit comments