Skip to content

Spurious COMPOSE_APPLIER_CALL_MISMATCH warnings between MapboxMap's style and content lambda slots on Kotlin 2.2.20+ (K2) #2720

@gil-lightyx

Description

@gil-lightyx

Environment

Mapbox Maps Android com.mapbox.extension:maps-compose-ndk27:11.23.0
Kotlin 2.3.21 (K2)
Compose plugin org.jetbrains.kotlin.plugin.compose 2.3.21
Android Gradle Plugin 9.2.0
Compose BOM 2026.04.01

Reproduction

MapboxMap(
    style = {
        MapStyle(
            style = """{"version": 8}""",
            styleState = rememberStyleState(),
        )
    },
) {
    BackgroundLayer { backgroundColor = ColorValue(Color.White) }
    DisposableMapEffect(Unit) { _ -> onDispose {} }
}

Observed warnings

At MapStyle(...) inside style = { ... }:

Calling a Mapbox Style Composable composable function where a UI Composable
composable was expected

At BackgroundLayer { ... } and DisposableMapEffect(...) inside the trailing
content lambda:

Calling a Mapbox Map Composable composable function where a Mapbox Style
Composable composable was expected

The markers appear shifted by one slot: style is inferred as plain UI, while
content is inferred as @MapboxStyleComposable. Slot placement matches the
documented signature in MapboxMap.kt:

style: @Composable @MapboxStyleComposable () -> Unit = { MapboxStandardStyle() },
content: (@Composable @MapboxMapComposable MapboxMapScope.() -> Unit)? = null

Why this is new

Kotlin 2.2.20 enabled @ComposableTarget enforcement on K2 (release
notes
). These warnings were silent
before — any latent issue with the marker annotations on MapboxMap's slots only
surfaces now.

This is the same class of false positive that googlemaps/android-maps-compose hit
in #598 and
resolved library-side via PR #763.

Related: ViewAnnotation

The content slot of ViewAnnotation is annotated @MapboxMapComposable, but its
purpose is to host plain UI. Calling Box/Text inside produces the inverse
warning:

Calling a UI Composable composable function where a Mapbox Map Composable
composable was expected

Likely fix

Annotation placement on the slot lambdas in MapboxMap.kt and ViewAnnotation.kt.
The style and content markers in MapboxMap may need different declaration
ordering, and ViewAnnotation's content slot should probably drop
@MapboxMapComposable.

Workaround (consumer side)

@Suppress(
    "COMPOSE_APPLIER_CALL_MISMATCH",
    "COMPOSE_APPLIER_PARAMETER_MISMATCH",
    "COMPOSE_APPLIER_DECLARATION_MISMATCH",
)
@Composable
fun MyMapScreen() { ... }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🪲Something isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions