Skip to content

Kotlin: Fix varargs dataflow, and varargs default handling#10909

Merged
smowton merged 1 commit intogithub:mainfrom
smowton:smowton/fix/kotlin-varargs-dataflow
Oct 21, 2022
Merged

Kotlin: Fix varargs dataflow, and varargs default handling#10909
smowton merged 1 commit intogithub:mainfrom
smowton:smowton/fix/kotlin-varargs-dataflow

Conversation

@smowton
Copy link
Copy Markdown
Contributor

@smowton smowton commented Oct 20, 2022

Dataflow requires accounting for the fact that the varargs parameter isn't necessarily last in the parameter list in a couple more places. Default handling just requires that if the only null parameter is the varargs argument, and it has no default value, then no $default method is required-- the caller is expected to simply pass nothing (at QL / source level) or an empty array (at JVM level).

Copy link
Copy Markdown
Contributor

@tamasvajk tamasvajk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found one minor issue, otherwise looks good to me.

import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.varargParameterIndex
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import seems suspicious.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

Dataflow requires accounting for the fact that the varargs parameter isn't necessarily last in the parameter list in a couple more places. Default handling just requires that if the only null parameter is the varargs argument, and it has no default value, then no $default method is required-- the caller is expected to simply pass nothing (at QL
/ source level) or an empty array (at JVM level).
@smowton smowton force-pushed the smowton/fix/kotlin-varargs-dataflow branch from 7027654 to 1fe9e84 Compare October 21, 2022 10:14
Copy link
Copy Markdown
Contributor

@aschackmull aschackmull left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QL changes LGTM.

@smowton smowton added the no-change-note-required This PR does not need a change note label Oct 21, 2022
@smowton smowton merged commit 5e28e5a into github:main Oct 21, 2022
smowton added a commit to smowton/codeql that referenced this pull request Nov 1, 2022
…r just because there are no varargs

This is the constructor case of github#10909
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java Kotlin no-change-note-required This PR does not need a change note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants