@@ -14,20 +14,9 @@ predicate instanceofThisInCharPred(Class c, Type type) {
1414 |
1515 instanceOf .getExpr ( ) instanceof ThisAccess and
1616 type = instanceOf .getType ( ) .getResolvedType ( )
17- )
18- }
19-
20- /**
21- * Holds if `c` uses the casting based range pattern, which could be replaced with `instanceof type`.
22- */
23- predicate usesCastingBasedInstanceof ( Class c , Type type ) {
24- instanceofThisInCharPred ( c , type ) and
25- // require that there is a call to the range class that matches the name of the enclosing predicate
26- exists ( InlineCast cast , MemberCall call |
27- cast = getAThisCast ( c , type ) and
28- call .getBase ( ) = cast and
29- cast .getEnclosingPredicate ( ) .getName ( ) = call .getMemberName ( )
30- )
17+ ) and
18+ // no existing super-type corresponds to the instanceof type, that is benign.
19+ not c .getType ( ) .getASuperType + ( ) = type
3120}
3221
3322/** Gets an inline cast that cases `this` to `type` inside a class predicate for `c`. */
@@ -40,7 +29,7 @@ InlineCast getAThisCast(Class c, Type type) {
4029 )
4130}
4231
43- predicate usesFieldBasedInstanceof ( Class c , TypeExpr type , FieldDecl field , ComparisonFormula comp ) {
32+ predicate usesFieldBasedInstanceof ( Class c , Type type , FieldDecl field , ComparisonFormula comp ) {
4433 exists ( FieldAccess fieldAccess |
4534 c .getCharPred ( ) .getBody ( ) = comp or
4635 c .getCharPred ( ) .getBody ( ) .( Conjunction ) .getAnOperand ( ) = comp
@@ -50,14 +39,9 @@ predicate usesFieldBasedInstanceof(Class c, TypeExpr type, FieldDecl field, Comp
5039 comp .getAnOperand ( ) instanceof ThisAccess and
5140 comp .getAnOperand ( ) = fieldAccess and
5241 fieldAccess .getDeclaration ( ) = field and
53- field .getVarDecl ( ) .getTypeExpr ( ) = type
42+ field .getVarDecl ( ) .getType ( ) = type
5443 ) and
55- // require that there is a call to the range field that matches the name of the enclosing predicate
56- exists ( FieldAccess access , MemberCall call |
57- access = getARangeFieldAccess ( c , field , _) and
58- call .getBase ( ) = access and
59- access .getEnclosingPredicate ( ) .getName ( ) = call .getMemberName ( )
60- )
44+ not c .getType ( ) .getASuperType + ( ) = type
6145}
6246
6347FieldAccess getARangeFieldAccess ( Class c , FieldDecl field , string name ) {
0 commit comments