File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change @@ -1466,8 +1466,8 @@ void TypeChecker::checkIgnoredExpr(Expr *E) {
1466
1466
isa<DotSyntaxCallExpr>(E) ? cast<DotSyntaxCallExpr>(E)->getFn () : E;
1467
1467
1468
1468
if (auto *Fn = dyn_cast<ApplyExpr>(expr)) {
1469
- if (auto *declRef = dyn_cast<DeclRefExpr>( Fn->getFn () )) {
1470
- if (auto *FD = dyn_cast<AbstractFunctionDecl>(declRef-> getDecl () )) {
1469
+ if (auto *calledValue = Fn->getCalledValue ( )) {
1470
+ if (auto *FD = dyn_cast<AbstractFunctionDecl>(calledValue )) {
1471
1471
if (FD->getAttrs ().hasAttribute <DiscardableResultAttr>()) {
1472
1472
isDiscardable = true ;
1473
1473
}
Original file line number Diff line number Diff line change @@ -222,3 +222,23 @@ class Discard {
222
222
bar // expected-error {{expression resolves to an unused function}}
223
223
}
224
224
}
225
+
226
+ // SR-12271
227
+
228
+ struct SR_12271_S {
229
+ @discardableResult
230
+ func bar1( ) -> ( ) -> Void {
231
+ return { }
232
+ }
233
+
234
+ @discardableResult
235
+ static func bar2( ) -> ( ) -> Void {
236
+ return { }
237
+ }
238
+ }
239
+
240
+ SR_12271_S ( ) . bar1 ( ) // Okay
241
+ SR_12271_S . bar2 ( ) // Okay
242
+
243
+ SR_12271_S ( ) . bar1 // expected-error {{expression resolves to an unused function}}
244
+ SR_12271_S . bar2 // expected-error {{expression resolves to an unused function}}
You can’t perform that action at this time.
0 commit comments