mapbox / mapbox/mapbox-maps-android

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

Open
#2,720 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug :beetle: ticketed
Dominant language
Kotlin
Stars
578
Forks
161
PR merge metrics
No merged PRs in 30d

Description

### 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

```kotlin
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`:

```kotlin
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](https://kotlinlang.org/docs/whatsnew2220.html)). 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](https://github.com/googlemaps/android-maps-compose/issues/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)

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MapboxMap.kt and ViewAnnotation.kt, then reproduce the sample under Kotlin 2.2.20+ with K2 to observe the shifted COMPOSE_APPLIER_CALL_MISMATCH warnings. Inspect the marker annotations on the style, content, and ViewAnnotation slots. Done means the documented slot usage no longer produces these false-positive warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.