@@ -11,6 +11,25 @@ abstract class IdentifierHiddenSharedQuery extends Query { }
1111
1212Query getQuery ( ) { result instanceof IdentifierHiddenSharedQuery }
1313
14+ /**
15+ * There is a lambda that contains a declaration
16+ * that hides something that is captured
17+ * and the lambda exists in the function where this lamda is enclosed
18+ */
19+ predicate hiddenInLambda ( UserDeclaration v2 , UserDeclaration v1 ) {
20+ exists ( Scope s , Closure le |
21+ s .getADeclaration ( ) = v2 and
22+ s .getAnAncestor ( ) = le and
23+ le .getEnclosingFunction ( ) .getBasicBlock ( ) .( Scope ) = v1 .getParentScope ( ) and
24+ exists ( LambdaCapture cap , Variable v |
25+ v .getAnAccess ( ) = cap .getInitializer ( ) .( VariableAccess ) and
26+ v = v1 and
27+ le .getLambdaExpression ( ) .getACapture ( ) = cap
28+ ) and
29+ v2 .getName ( ) = v1 .getName ( )
30+ )
31+ }
32+
1433query predicate problems ( UserDeclaration v2 , string message , UserDeclaration v1 , string varName ) {
1534 not isExcluded ( v1 , getQuery ( ) ) and
1635 not isExcluded ( v2 , getQuery ( ) ) and
@@ -20,7 +39,7 @@ query predicate problems(UserDeclaration v2, string message, UserDeclaration v1,
2039 //ignore types for this rule
2140 not v2 instanceof Type and
2241 not v1 instanceof Type and
23- hidesStrict ( v1 , v2 ) and
42+ ( hidesStrict ( v1 , v2 ) or hiddenInLambda ( v2 , v1 ) ) and
2443 not excludedViaNestedNamespaces ( v2 , v1 ) and
2544 varName = v1 .getName ( ) and
2645 message = "Declaration is hiding declaration $@."
0 commit comments