Skip to content

Runtime IrLinkageError exception when accessing AppScope dependency graph #1627

@IanDBird

Description

@IanDBird

Description

I have a multi-platform mobile application that targets both iOS and Android. After upgrading Kotlin to 2.3.0, i'm experiencing a runtime crash that only occurs on iOS. Some details to my setup are as follows:

  • I have a common AppObjectGraph (expect) and two separate implementations for Android and iOS
  • Both actual implementations expose a logger via a variable
  • In the iOS actual implementation, i'm also inheriting from LoggingSubgraph
@DependencyGraph(AppScope::class)
actual interface ClientAppObjectGraph :
    BaseApplicationObjectGraph,
    HasClientViewObjectGraph,
    ClientAppManualBindings {
...
    val logger: Logger
}
interface ClientAppManualBindings :
    LoggingSubgraph,
    ...
@ContributesTo(AppScope::class)
interface LoggingSubgraph {
    @Provides
    @SingleIn(AppScope::class)
    fun providesLogger(): Logger = KermitLogger(
        Kermit(
            config = StaticConfig(
                minSeverity = KermitSeverity.Debug,
            ),
        ),
    )
}

The runtime crash occurs on iOS when it creates the AppObjectGraph and tries to access the logger:

class AppState {
    static let shared = AppState()

    fileprivate let appObjectGraph: ClientAppObjectGraph = createApplicationObjectGraph()
}

extension AppState {
    var logger: any Shared.Logger {
        appObjectGraph.logger <-- Crash
    }
}

The crash is:

Function doesn't have or inherit @throws annotation and thus exception isn't propagated from Kotlin to Objective-C/Swift as NSError.
It is considered unexpected and unhandled instead. Program will be terminated.
Uncaught Kotlin exception: kotlin.internal.IrLinkageError: Abstract property accessor 'logger.' is not implemented in non-abstract class 'Impl'

Self-contained Reproducer

I'll try to provide a small repro separately.

Metro version

0.9.2

Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions