@@ -70,7 +70,7 @@ abstract class Completion extends TCompletion {
70
70
predicate isValidFor ( ControlFlowElement n ) {
71
71
this .isValidForSpecific ( n )
72
72
or
73
- mayHaveThrowCompletion ( n . asAstNode ( ) , this )
73
+ mayHaveThrowCompletion ( n , this )
74
74
or
75
75
not any ( Completion c ) .isValidForSpecific ( n ) and
76
76
this = TSimpleCompletion ( )
@@ -328,10 +328,16 @@ private predicate isMatchingConstant(CaseLabelItem cli, boolean value) {
328
328
329
329
private predicate mustHaveThrowCompletion ( ThrowStmt throw , ThrowCompletion c ) { any ( ) }
330
330
331
- private predicate mayHaveThrowCompletion ( ApplyExpr n , ThrowCompletion c ) {
332
- // TODO: We should really just use the function type here, I think (and then check
333
- // if the type has a `throws`).
334
- exists ( n .getStaticTarget ( ) )
331
+ private predicate isThrowingType ( AnyFunctionType type ) { type .isThrowing ( ) }
332
+
333
+ private predicate mayHaveThrowCompletion ( ControlFlowElement n , ThrowCompletion c ) {
334
+ // An AST expression that may throw.
335
+ isThrowingType ( n .asAstNode ( ) .( ApplyExpr ) .getFunction ( ) .getType ( ) )
336
+ or
337
+ // Getters are the only accessor declarators that may throw.
338
+ exists ( AccessorDecl accessor | isThrowingType ( accessor .getInterfaceType ( ) ) |
339
+ isPropertyGetterElement ( n , accessor , _)
340
+ )
335
341
}
336
342
337
343
/**
0 commit comments