@@ -66,23 +66,15 @@ private module Initializers {
6666}
6767
6868/** An element that defines a new CFG scope. */
69- class CfgScope extends Element , @top_level_exprorstmt_parent {
69+ class CfgScope extends Callable {
7070 CfgScope ( ) {
7171 this .getFile ( ) .fromSource ( ) and
7272 (
73- this =
74- any ( Callable c |
75- c .( Constructor ) .hasInitializer ( )
76- or
77- Initializers:: obinitInitializes ( c , _)
78- or
79- c .hasBody ( )
80- )
73+ this .( Constructor ) .hasInitializer ( )
8174 or
82- // For now, static initializer values have their own scope. Eventually, they
83- // should be treated like instance initializers.
84- this .( Assignable ) .( Modifiable ) .isStatic ( ) and
85- expr_parent_top_level_adjusted2 ( _, _, this )
75+ Initializers:: obinitInitializes ( this , _)
76+ or
77+ this .hasBody ( )
8678 )
8779 }
8880}
@@ -189,24 +181,6 @@ CompilationExt getCompilation(File f) {
189181 result = TBuildless ( )
190182}
191183
192- /**
193- * The `expr_parent_top_level_adjusted()` relation restricted to exclude relations
194- * between properties and their getters' expression bodies in properties such as
195- * `int P => 0`.
196- *
197- * This is in order to only associate the expression body with one CFG scope, namely
198- * the getter (and not the declaration itself).
199- */
200- private predicate expr_parent_top_level_adjusted2 (
201- Expr child , int i , @top_level_exprorstmt_parent parent
202- ) {
203- expr_parent_top_level_adjusted ( child , i , parent ) and
204- not exists ( Getter g |
205- g .getDeclaration ( ) = parent and
206- i = 0
207- )
208- }
209-
210184/** Holds if `first` is first executed when entering `scope`. */
211185predicate scopeFirst ( CfgScope scope , AstNode first ) {
212186 scope =
@@ -220,9 +194,6 @@ predicate scopeFirst(CfgScope scope, AstNode first) {
220194 )
221195 or
222196 first ( Initializers:: initializedInstanceMemberOrder ( scope , _, 0 ) , first )
223- or
224- expr_parent_top_level_adjusted2 ( any ( Expr e | first ( e , first ) ) , _, scope ) and
225- not scope instanceof Callable
226197}
227198
228199/** Holds if `scope` is exited when `last` finishes with completion `c`. */
@@ -244,9 +215,6 @@ predicate scopeLast(CfgScope scope, AstNode last, Completion c) {
244215 )
245216 or
246217 last ( Initializers:: lastInitializer ( scope , _) , last , c )
247- or
248- expr_parent_top_level_adjusted2 ( any ( Expr e | last ( e , last , c ) ) , _, scope ) and
249- not scope instanceof Callable
250218}
251219
252220private class ObjectInitTree extends ControlFlowTree instanceof ObjectInitMethod {
0 commit comments