@@ -10,6 +10,7 @@ private import FlowSummaryImpl::Private
10
10
private import FlowSummaryImpl:: Public
11
11
private import semmle.code.java.dataflow.ExternalFlow
12
12
private import semmle.code.java.dataflow.FlowSummary as FlowSummary
13
+ private import semmle.code.java.dataflow.internal.AccessPathSyntax as AccessPathSyntax
13
14
14
15
class SummarizedCallableBase = FlowSummary:: SummarizedCallableBase ;
15
16
@@ -84,6 +85,9 @@ private predicate relatedArgSpec(Callable c, string spec) {
84
85
* for the additional dispatch receiver parameter that occurs in the default-parameter proxy's argument
85
86
* list. When no adjustment is required (e.g. for constructors, or non-argument-based specs), `defaultArgsSpec`
86
87
* equals `originalArgSpec`.
88
+ *
89
+ * Note in the case where `originalArgSpec` uses an integer range, like `Argument[1..3]...`, this will produce multiple
90
+ * results for `defaultsArgSpec`, like `{Argument[2]..., Argument[3]..., Argument[4]...}`.
87
91
*/
88
92
private predicate correspondingKotlinParameterDefaultsArgSpec (
89
93
Callable originalCallable , Callable defaultsCallable , string originalArgSpec ,
@@ -98,19 +102,21 @@ private predicate correspondingKotlinParameterDefaultsArgSpec(
98
102
exists ( string regex |
99
103
// Note I use a regex and not AccessPathToken because this feeds summaryElement et al,
100
104
// which would introduce mutual recursion with the definition of AccessPathToken.
101
- regex = "Argument\\[([0-9]+)\\](.*)" and
105
+ regex = "Argument\\[([0-9,\\. ]+)\\](.*)" and
102
106
(
103
107
exists ( string oldArgNumber , string rest , int paramOffset |
104
108
oldArgNumber = originalArgSpec .regexpCapture ( regex , 1 ) and
105
109
rest = originalArgSpec .regexpCapture ( regex , 2 ) and
106
110
paramOffset =
107
- (
108
- defaultsCallable .getNumberOfParameters ( ) -
109
- ( originalCallable .getNumberOfParameters ( ) + 2 )
110
- ) and
111
- if ktExtensionFunctions ( originalCallable , _, _) and oldArgNumber = "0"
112
- then defaultsArgSpec = originalArgSpec
113
- else defaultsArgSpec = "Argument[" + ( oldArgNumber .toInt ( ) + paramOffset ) + "]" + rest
111
+ defaultsCallable .getNumberOfParameters ( ) -
112
+ ( originalCallable .getNumberOfParameters ( ) + 2 ) and
113
+ exists ( int oldArgParsed |
114
+ oldArgParsed = AccessPathSyntax:: AccessPath:: parseInt ( oldArgNumber .splitAt ( "," ) .trim ( ) )
115
+ |
116
+ if ktExtensionFunctions ( originalCallable , _, _) and oldArgParsed = 0
117
+ then defaultsArgSpec = "Argument[0]"
118
+ else defaultsArgSpec = "Argument[" + ( oldArgParsed + paramOffset ) + "]" + rest
119
+ )
114
120
)
115
121
or
116
122
not originalArgSpec .regexpMatch ( regex ) and
0 commit comments