Skip to content

[K/N] Implement new class initialization order.#6517

Open
Alexander Shabalin (projedi) wants to merge 1 commit into
masterfrom
alshabalin/KT-87412/new-native-initialization
Open

[K/N] Implement new class initialization order.#6517
Alexander Shabalin (projedi) wants to merge 1 commit into
masterfrom
alshabalin/KT-87412/new-native-initialization

Conversation

@projedi

Copy link
Copy Markdown
Member

When CompanionBlocksAndExtensions language feature is enabled, the classes should follow JVM-like initialization scheme:

  • first, the superclass should be initialized
  • next, all superinterfaces with at least one non-static non-abstract method should be (recursively) initialized in the declaration order
  • initialization of companion blocks and companion object should follow program order

^KT-87412

@@ -99,6 +126,52 @@ internal class StaticInitializersLowering(val context: Context) : FileLoweringPa

val builder = context.irBuiltIns.createIrBuilder((container as IrSymbolOwner).symbol, SYNTHETIC_OFFSET, SYNTHETIC_OFFSET)

if (container is IrClass && !container.isInterface && container.konanLibrary?.newCompanionInitializationEnabled == true) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

When `CompanionBlocksAndExtensions` language feature is enabled,
the classes should follow JVM-like initialization scheme:
- first, the superclass should be initialized
- next, all superinterfaces with at least one non-static non-abstract
  method should be (recursively) initialized in the declaration order
- initialization of `companion` blocks and `companion object` should follow
  program order

^KT-87412
@projedi Alexander Shabalin (projedi) force-pushed the alshabalin/KT-87412/new-native-initialization branch from 8d3b309 to aa45e5c Compare July 3, 2026 11:24
@@ -0,0 +1,348 @@
// See companionInitOrderWithSuperclass for the common treatment.
// TARGET_BACKEND: NATIVE
// LANGUAGE: +CompanionBlocksAndExtensions

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This copy-pasting is super silly, but I don't know how to enable language feature only for the single backend.

@projedi

Copy link
Copy Markdown
Member Author

/dry-run

@KotlinBuild

Build Server (KotlinBuild) commented Jul 3, 2026

Copy link
Copy Markdown

THIS IS A DRY RUN

Quality gate is triggered at https://buildserver.labs.intellij.net/build/992929408 — use this link to get full insight.

Quality gate was triggered with the following revisions:

kotlin
Branch: refs/merge/GITHUB-6517/safe-merge
Commit: ed6b2e7


Quality gate failed. See https://buildserver.labs.intellij.net/build/992929408 to get full insight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants