File tree Expand file tree Collapse file tree
lib/codeql/unified/internal
test/library-tests/static-name-binding Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,12 +53,6 @@ module StaticNameResolutionStats implements EntityStatsSig {
5353 or
5454 result .isModuleScopeNode ( _) and
5555 result .( NamespaceNode ) .ref ( ) .isIdentifier ( this )
56- ) and
57- // Do not consider a type extension to be a valid target
58- // TODO: Fix in the AST mapping: type extensions should reference their type, not declare it
59- not exists ( ClassLikeDeclaration cls |
60- cls .hasModifier ( "extension" ) and
61- result .isIdentifier ( cls .getName ( ) )
6256 )
6357 }
6458
Original file line number Diff line number Diff line change @@ -231,6 +231,7 @@ private module LocalNameBindingInput implements LocalNameBindingInputSig<Locatio
231231 exists ( ClassLikeDeclaration cls |
232232 getChild ( scope , _) = cls and
233233 pattern = cls .getName ( ) and
234+ not cls .hasModifier ( "extension" ) and // TODO: Fix in the AST mapping: type extensions should reference their type, not declare it
234235 declaration = cls
235236 )
236237 or
@@ -382,6 +383,8 @@ class PotentialLocalNameAccess extends Identifier {
382383 this = any ( NamedTypeExpr e | not exists ( e .getQualifier ( ) ) ) .getName ( )
383384 or
384385 this instanceof NameDeclaration
386+ or
387+ this = any ( ClassLikeDeclaration cls | cls .hasModifier ( "extension" ) ) .getName ( ) // TODO: Fix in the AST mapping: type extensions should reference their type, not declare it
385388 }
386389
387390 LocalName getLocalName ( ) { result = this .( LocalNameBindingOutput:: LocalAccess ) .getLocal ( ) }
Original file line number Diff line number Diff line change @@ -476,7 +476,6 @@ private module FolderHeuristic {
476476 exists ( TopLevel top , Stmt stmt , NameDeclaration nameDecl |
477477 top .getFile ( ) = file and
478478 stmt = top .getBody ( ) .getAStmt ( ) and
479- not stmt .( ClassLikeDeclaration ) .hasModifier ( "extension" ) and // TODO: target of type extensions should not be seen as a NameDeclaration
480479 not isPrivateToLocalScope ( nameDecl ) and
481480 nameDecl .getDeclaration ( ) = stmt and
482481 name = nameDecl .getName ( ) and
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ class F {
4646typealias G = A // $ access=A
4747
4848// Members can be accessed through aliases, but references to the alias itself do not bypass the alias.
49- class H {
49+ class H { // name=H1
5050 let x1 : G = nil ; // $ access=G
5151 let x2 : G . B = nil ; // $ access=G access=A.B
5252 let x3 : G . B . C = nil ; // $ access=G access=A.B access=A.B.C
@@ -62,3 +62,11 @@ func useI() {
6262 I . two // $ access=I access=I.two
6363 I . three // $ access=I access=I.three
6464}
65+
66+ protocol P { }
67+
68+ extension H // $ access=H1
69+ : P { } // $ access=P
70+
71+ extension A . B . C // $ MISSING: access=A access=A.B access=A.B.C (`A.B.C` is currently parsed as a single identifier)
72+ : P { } // $ access=P
You can’t perform that action at this time.
0 commit comments