File tree Expand file tree Collapse file tree
lib/codeql/unified/internal
test/library-tests/type-inference Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -99,7 +99,8 @@ predicate isStaticMember(Member member) {
9999 exists ( ClassLikeDeclaration cls | cls .getAMember ( ) = member |
100100 not any ( NameBindingPlugin p ) .isInstanceMember ( cls , member ) or
101101 member instanceof ConstructorDeclaration or
102- member instanceof TypeAliasDeclaration
102+ member instanceof TypeAliasDeclaration or
103+ member instanceof ClassLikeDeclaration
103104 )
104105 or
105106 member = any ( TopLevel t ) .getBody ( ) .getAStmt ( )
Original file line number Diff line number Diff line change @@ -101,6 +101,12 @@ abstract private class TypeImpl extends TType {
101101 )
102102 }
103103
104+ /** Gets the parent type of this nested type, if any. */
105+ ClassLikeDeclarationType getParentType ( ) {
106+ result .getClassLikeDeclaration ( ) =
107+ this .getATypeParameter ( ) .( ParentTypeParameterType ) .getParent ( )
108+ }
109+
104110 /** Gets the name node of this type, if any. */
105111 abstract Identifier getNameNode ( ) ;
106112
Original file line number Diff line number Diff line change 22
33/*
44 * Known limitations:
5- * - Implicit constructors in classes and structs are not generated by the extractor
65 * - Pattern matching, including enum destructuring
76 * - Inferred qualifiers `.foo`
87 * - Type parameter bounds (`foo<T : Protocol>(x : T)`)
1514 * - Overloading (both arity based and type based)
1615 * - Indexing expressions
1716 * - Operations
18- * - Inherited constructors
1917 * - Closure short-hand parameters `$0`, `$1`, etc (extractor change?)
2018 */
2119
@@ -851,8 +849,9 @@ module Input3 implements InputSig3 {
851849 // `Optional.none` has an unknown `Wrapper` type
852850 exists ( EnumField_ f , TypeParameter tp |
853851 n .( FieldAccess ) .getField ( ) = f and
854- tp = f .getType ( ) .getType ( ) .getATypeParameter ( ) and
855- path = TypePath:: singleton ( tp ) and
852+ tp = f .getType ( ) .getType ( ) .getParentType * ( ) .getATypeParameter ( ) and
853+ not tp instanceof ParentTypeParameterType and
854+ tp = f .getType ( ) .getTypeAt ( path ) and
856855 // `Optional<String>.none` does not have an unknown `Wrapper` type
857856 not exists ( n .( MemberAccessExpr ) .getBase ( ) .( TypeMention ) .getTypeAt ( path ) )
858857 ) and
Original file line number Diff line number Diff line change @@ -114,8 +114,12 @@ class Outer<TOuter> {
114114 let c = p2 . 0 . getOuter ( ) // $ target=Outer.Inner.getOuter field=Tuple2.0 type=c:Bool
115115 let d = p2 . 0 . getInner ( ) // $ target=Outer.Inner.getInner field=Tuple2.0 type=d:Int
116116 }
117+
118+ enum E { case empty }
117119}
118120
121+ let e : Outer < Int > . E = Outer . E . empty // $ field=Outer.E.empty type=.empty@Outer.E<(parent:E)>.Outer<TOuter>:Int
122+
119123class Foo : Outer < String > {
120124 func f ( x : Pair , y : Outer < Bool > . Pair ) {
121125 var a = x . 0 . getInner ( ) // $ target=Outer.Inner.getInner field=Tuple2.0 type=a:Int
You can’t perform that action at this time.
0 commit comments