From 2c0dcd3a2d03e8cf363099d9e01cf77f69c3c485 Mon Sep 17 00:00:00 2001 From: Marcono1234 Date: Sat, 7 Oct 2023 03:38:19 +0200 Subject: [PATCH] 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 { C() { } } new C(); ``` And those are not part of the results of these predicates. --- java/ql/lib/semmle/code/java/Expr.qll | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/java/ql/lib/semmle/code/java/Expr.qll b/java/ql/lib/semmle/code/java/Expr.qll index 81c5dc64aea..fa95b745aea 100644 --- a/java/ql/lib/semmle/code/java/Expr.qll +++ b/java/ql/lib/semmle/code/java/Expr.qll @@ -1199,15 +1199,15 @@ class ClassInstanceExpr extends Expr, ConstructorCall, @classinstancexpr { } /** - * Gets a type argument provided to the constructor of this class instance creation expression. + * Gets a type argument of the type of the created instance. * - * This is used for instantiations of parameterized classes. + * This is used for instantiations of parameterized classes. For example for + * `new ArrayList()` the result would be the expression representing `String`. */ Expr getATypeArgument() { result = this.getTypeName().(TypeAccess).getATypeArgument() } /** - * Gets the type argument provided to the constructor of this class instance creation expression - * at the specified (zero-based) position. + * Gets the type argument of the type of the created instance, at the specified (zero-based) position. */ Expr getTypeArgument(int index) { result = this.getTypeName().(TypeAccess).getTypeArgument(index)