File tree Expand file tree Collapse file tree 2 files changed +28
-13
lines changed Expand file tree Collapse file tree 2 files changed +28
-13
lines changed Original file line number Diff line number Diff line change @@ -189,23 +189,24 @@ void PostfixCompletionCallback::sawSolutionImpl(
189
189
190
190
bool BaseIsStaticMetaType = S.isStaticallyDerivedMetatype (ParsedExpr);
191
191
192
+ bool ExpectsNonVoid = false ;
192
193
SmallVector<Type, 4 > ExpectedTypes;
193
194
if (ExpectedTy) {
194
195
ExpectedTypes.push_back (ExpectedTy);
195
- }
196
-
197
- bool ExpectsNonVoid = false ;
198
- ExpectsNonVoid |= ExpectedTy && !ExpectedTy->isVoid ();
199
- ExpectsNonVoid |=
200
- !ParentExpr && CS.getContextualTypePurpose (CompletionExpr) != CTP_Unused;
196
+ ExpectsNonVoid = !ExpectedTy->isVoid ();
197
+ } else {
198
+ ExpectsNonVoid |= !ParentExpr &&
199
+ CS.getContextualTypePurpose (CompletionExpr) != CTP_Unused;
201
200
202
- for (auto SAT : S.targets ) {
203
- if (ExpectsNonVoid) {
204
- // ExpectsNonVoid is already set. No need to iterate further.
205
- break ;
206
- }
207
- if (SAT.second .getAsExpr () == CompletionExpr) {
208
- ExpectsNonVoid |= SAT.second .getExprContextualTypePurpose () != CTP_Unused;
201
+ for (auto SAT : S.targets ) {
202
+ if (ExpectsNonVoid) {
203
+ // ExpectsNonVoid is already set. No need to iterate further.
204
+ break ;
205
+ }
206
+ if (SAT.second .getAsExpr () == CompletionExpr) {
207
+ ExpectsNonVoid |=
208
+ SAT.second .getExprContextualTypePurpose () != CTP_Unused;
209
+ }
209
210
}
210
211
}
211
212
Original file line number Diff line number Diff line change @@ -190,6 +190,20 @@ struct TestSingleExprFunc {
190
190
// TestSingleExprFunc-DAG: Decl[InstanceMethod]/CurrNominal: void()[#Void#];
191
191
}
192
192
193
+ struct TestSingleExprFuncReturnVoid {
194
+ func void( ) -> Void { }
195
+ func str( ) -> String { return " " }
196
+ func int( ) -> Int { return 0 }
197
+
198
+ func test( ) {
199
+ return self . #^TestSingleExprFuncReturnVoid^#
200
+ }
201
+
202
+ // TestSingleExprFuncReturnVoid-DAG: Decl[InstanceMethod]/CurrNominal: str()[#String#];
203
+ // TestSingleExprFuncReturnVoid-DAG: Decl[InstanceMethod]/CurrNominal: int()[#Int#];
204
+ // TestSingleExprFuncReturnVoid-DAG: Decl[InstanceMethod]/CurrNominal/TypeRelation[Convertible]: void()[#Void#];
205
+ }
206
+
193
207
struct TestSingleExprFuncUnresolved {
194
208
enum MyEnum { case myEnum }
195
209
enum NotMine { case notMine }
You can’t perform that action at this time.
0 commit comments