-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Kotlin: Support Kotlin 2.3.0-Beta2 #20965
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
2264e55
8e47847
b82e556
ed9da7b
1af9e11
b65c116
fa58841
2fdca62
931468e
27a75e9
9358c64
f19f5dc
1e08d19
316c0fc
134ac3b
dd29598
f44af14
845c486
e3f2df4
0a56625
d0199ce
aa9dd59
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,7 +27,7 @@ | |
| import io | ||
| import os | ||
|
|
||
| DEFAULT_VERSION = "2.2.0" | ||
| DEFAULT_VERSION = "2.3.0" | ||
|
|
||
|
|
||
| def options(): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -415,6 +415,7 @@ open class KotlinFileExtractor( | |
|
|
||
| private fun extractClassModifiers(c: IrClass, id: Label<out DbClassorinterface>) { | ||
| with("class modifiers", c) { | ||
| @Suppress("REDUNDANT_ELSE_IN_WHEN") | ||
| when (c.modality) { | ||
| Modality.FINAL -> addModifiers(id, "final") | ||
| Modality.SEALED -> addModifiers(id, "sealed") | ||
|
|
@@ -1342,7 +1343,7 @@ open class KotlinFileExtractor( | |
| extractTypeAccessRecursive(substitutedType, location, id, -1) | ||
| } | ||
| val syntheticParameterNames = | ||
| isUnderscoreParameter(vp) || | ||
| vp.origin == IrDeclarationOrigin.UNDERSCORE_PARAMETER || | ||
| ((vp.parent as? IrFunction)?.let { hasSynthesizedParameterNames(it) } ?: true) | ||
| val javaParameter = | ||
| when (val callable = (vp.parent as? IrFunction)?.let { getJavaCallable(it) }) { | ||
|
|
@@ -1644,7 +1645,7 @@ open class KotlinFileExtractor( | |
| extractMethodAndParameterTypeAccesses: Boolean, | ||
| typeSubstitution: TypeSubstitution?, | ||
| classTypeArgsIncludingOuterClasses: List<IrTypeArgument>? | ||
| ) = | ||
| ) : Label<out DbCallable> = | ||
| forceExtractFunction( | ||
| f, | ||
| parentId, | ||
|
|
@@ -2801,6 +2802,7 @@ open class KotlinFileExtractor( | |
|
|
||
| private fun extractBody(b: IrBody, callable: Label<out DbCallable>) { | ||
| with("body", b) { | ||
| @Suppress("REDUNDANT_ELSE_IN_WHEN") | ||
| when (b) { | ||
| is IrBlockBody -> extractBlockBody(b, callable) | ||
| is IrSyntheticBody -> extractSyntheticBody(b, callable) | ||
|
|
@@ -2834,7 +2836,7 @@ open class KotlinFileExtractor( | |
| when { | ||
| kind == IrSyntheticBodyKind.ENUM_VALUES -> tw.writeKtSyntheticBody(callable, 1) | ||
| kind == IrSyntheticBodyKind.ENUM_VALUEOF -> tw.writeKtSyntheticBody(callable, 2) | ||
| kind == kind_ENUM_ENTRIES -> tw.writeKtSyntheticBody(callable, 3) | ||
| kind == IrSyntheticBodyKind.ENUM_ENTRIES -> tw.writeKtSyntheticBody(callable, 3) | ||
| else -> { | ||
| logger.errorElement("Unhandled synthetic body kind " + kind, b) | ||
| } | ||
|
|
@@ -2973,13 +2975,23 @@ open class KotlinFileExtractor( | |
| val locId = tw.getLocation(s) | ||
| tw.writeStmts_block(blockId, parent, idx, callable) | ||
| tw.writeHasLocation(blockId, locId) | ||
| extractVariable(s.delegate, callable, blockId, 0) | ||
|
|
||
| // For Kotlin < 2.3, s.delegate is not-nullable. Cast to be nullable, | ||
| // as a workaround to silence warnings for kotlin < 2.3 about the elvis | ||
| // operator being redundant. | ||
| // For Kotlin >= 2.3, the cast is redundant, so we need to silence that warning | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you know why it is now nullable? Is that actually an error?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tbh, I have not dug into why it can be nullable. Let me take a look at the API to understand if its an error if its null.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copilot was very convincing in explaining that the delegate may become null after lowering. But as the extractor hooks into the pipeline before lowering, the delegate should always be set. |
||
| @Suppress("USELESS_CAST") | ||
| val delegate = s.delegate as IrVariable? | ||
| val propId = tw.getFreshIdLabel<DbKt_property>() | ||
| tw.writeKtProperties(propId, s.name.asString()) | ||
| tw.writeHasLocation(propId, locId) | ||
| tw.writeKtPropertyDelegates(propId, useVariable(s.delegate)) | ||
|
|
||
| if (delegate == null) { | ||
| // This is not expected to happen, as the plugin hooks into the pipeline before IR lowering. | ||
| logger.errorElement("Local delegated property is missing delegate", s) | ||
| } else { | ||
| extractVariable(delegate, callable, blockId, 0) | ||
| tw.writeKtProperties(propId, s.name.asString()) | ||
| tw.writeHasLocation(propId, locId) | ||
| tw.writeKtPropertyDelegates(propId, useVariable(delegate)) | ||
| } | ||
| // Getter: | ||
| extractStatement(s.getter, callable, blockId, 1) | ||
| val getterLabel = getLocallyVisibleFunctionLabels(s.getter).function | ||
|
|
@@ -3332,7 +3344,7 @@ open class KotlinFileExtractor( | |
| // that specified the default values, which will in turn dynamically dispatch back to the | ||
| // relevant override. | ||
| val overriddenCallTarget = | ||
| (callTarget as? IrSimpleFunction)?.allOverriddenIncludingSelf()?.firstOrNull { | ||
| (callTarget as? IrSimpleFunction)?.allOverridden(includeSelf = true)?.firstOrNull { | ||
| it.overriddenSymbols.isEmpty() && | ||
| it.valueParameters.any { p -> p.defaultValue != null } | ||
| } ?: callTarget | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm guessing the situation has improved since I did this, and the simple v is enough. making it work from @codeql is a nice to have, but it has to work from @codeql_kotlin_embeddable