Skip to content

Commit 2c0dcd3

Browse files
committed
Java: Adjust ClassInstanceExpr type argument predicates docs
The type arguments which these predicates have as result are for the type of the created instance. Previously the documentation said "provided to the constructor", which is misleading / incorrect. Type arguments provided to the constructor are specified directly after the `new` keyword: ``` class C { <T> C() { } } new <String> C(); ``` And those are not part of the results of these predicates.
1 parent eb3f196 commit 2c0dcd3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

java/ql/lib/semmle/code/java/Expr.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,15 +1199,15 @@ class ClassInstanceExpr extends Expr, ConstructorCall, @classinstancexpr {
11991199
}
12001200

12011201
/**
1202-
* Gets a type argument provided to the constructor of this class instance creation expression.
1202+
* Gets a type argument of the type of the created instance.
12031203
*
1204-
* This is used for instantiations of parameterized classes.
1204+
* This is used for instantiations of parameterized classes. For example for
1205+
* `new ArrayList<String>()` the result would be the expression representing `String`.
12051206
*/
12061207
Expr getATypeArgument() { result = this.getTypeName().(TypeAccess).getATypeArgument() }
12071208

12081209
/**
1209-
* Gets the type argument provided to the constructor of this class instance creation expression
1210-
* at the specified (zero-based) position.
1210+
* Gets the type argument of the type of the created instance, at the specified (zero-based) position.
12111211
*/
12121212
Expr getTypeArgument(int index) {
12131213
result = this.getTypeName().(TypeAccess).getTypeArgument(index)

0 commit comments

Comments
 (0)