mirror of
https://github.com/github/codeql.git
synced 2025-12-24 12:46:34 +01:00
Adjust getExtensionReceiverParameterIndex predicate name and change note
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The extraction of extension methods have been improved when default parameter values are present. The dispatch and extension receiver parameters are extracted in the correct order. The `ExtensionMethod::getExtensionParameterIndex` predicate has been introduced to facilitate getting the correct extension parameter index.
|
||||
* The extraction of Kotlin extension methods has been improved when default parameter values are present. The dispatch and extension receiver parameters are extracted in the correct order. The `ExtensionMethod::getExtensionReceiverParameterIndex` predicate has been introduced to facilitate getting the correct extension parameter index.
|
||||
|
||||
@@ -820,7 +820,7 @@ class ExtensionMethod extends Method {
|
||||
* extension methods that are defined as members, the index is 1. Index 0 is the dispatch receiver of the `$default`
|
||||
* method.
|
||||
*/
|
||||
int getExtensionParameterIndex() {
|
||||
int getExtensionReceiverParameterIndex() {
|
||||
if
|
||||
exists(Method src |
|
||||
this = src.getKotlinParameterDefaultsProxy() and
|
||||
|
||||
@@ -91,7 +91,7 @@ class Parameter extends Element, @param, LocalScopeVariable {
|
||||
|
||||
/** Holds if this formal parameter is a parameter representing the dispatch receiver in an extension method. */
|
||||
predicate isExtensionParameter() {
|
||||
this.getPosition() = this.getCallable().(ExtensionMethod).getExtensionParameterIndex()
|
||||
this.getPosition() = this.getCallable().(ExtensionMethod).getExtensionReceiverParameterIndex()
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -299,7 +299,8 @@ private class PathNormalizeSanitizer extends MethodAccess {
|
||||
*/
|
||||
private Expr getVisualQualifier(MethodAccess ma) {
|
||||
if ma.getMethod() instanceof ExtensionMethod
|
||||
then result = ma.getArgument(ma.getMethod().(ExtensionMethod).getExtensionParameterIndex())
|
||||
then
|
||||
result = ma.getArgument(ma.getMethod().(ExtensionMethod).getExtensionReceiverParameterIndex())
|
||||
else result = ma.getQualifier()
|
||||
}
|
||||
|
||||
@@ -313,7 +314,8 @@ private Argument getVisualArgument(MethodAccess ma, int argPos) {
|
||||
if ma.getMethod() instanceof ExtensionMethod
|
||||
then
|
||||
result =
|
||||
ma.getArgument(argPos + ma.getMethod().(ExtensionMethod).getExtensionParameterIndex() + 1)
|
||||
ma.getArgument(argPos + ma.getMethod().(ExtensionMethod).getExtensionReceiverParameterIndex() +
|
||||
1)
|
||||
else result = ma.getArgument(argPos)
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ query predicate extensionsMismatch(Method src, Method def) {
|
||||
|
||||
query predicate extensionIndex(ExtensionMethod m, int i, Type t) {
|
||||
m.fromSource() and
|
||||
m.getExtensionParameterIndex() = i and
|
||||
m.getExtensionReceiverParameterIndex() = i and
|
||||
m.getExtendedType() = t and
|
||||
m.getParameter(i).getType() = t
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user