@@ -11,6 +11,25 @@ abstract class IdentifierHiddenSharedQuery extends Query { }
11
11
12
12
Query getQuery ( ) { result instanceof IdentifierHiddenSharedQuery }
13
13
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
+
14
33
query predicate problems ( UserDeclaration v2 , string message , UserDeclaration v1 , string varName ) {
15
34
not isExcluded ( v1 , getQuery ( ) ) and
16
35
not isExcluded ( v2 , getQuery ( ) ) and
@@ -20,7 +39,7 @@ query predicate problems(UserDeclaration v2, string message, UserDeclaration v1,
20
39
//ignore types for this rule
21
40
not v2 instanceof Type and
22
41
not v1 instanceof Type and
23
- hidesStrict ( v1 , v2 ) and
42
+ ( hidesStrict ( v1 , v2 ) or hiddenInLambda ( v2 , v1 ) ) and
24
43
not excludedViaNestedNamespaces ( v2 , v1 ) and
25
44
varName = v1 .getName ( ) and
26
45
message = "Declaration is hiding declaration $@."
0 commit comments