hotwired / hotwired/hotwire-native-android
Can't access `delegate` in bridge component
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 163
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
I've copy-pasted the following into an existing Hotwire Native Android app from the Bridge Components section of the guide.
package com.masilotti.hikingjournal.components
import androidx.fragment.app.Fragment
import dev.hotwire.core.bridge.BridgeComponent
import dev.hotwire.core.bridge.BridgeDelegate
import dev.hotwire.core.bridge.Message
import dev.hotwire.navigation.destinations.HotwireDestination
class ButtonComponent(
name: String,
private val delegate: BridgeDelegate<HotwireDestination>
) : BridgeComponent<HotwireDestination>(name, delegate) {
private val fragment: Fragment
get() = delegate.destination.fragment
override fun onReceive(message: Message) {
TODO("Not yet implemented")
}
}
When I try to run the app it fails with the following error:
e: file://app/src/main/java/com/masilotti/hikingjournal/components/ButtonComponent.kt:9:7 Conflicting declarations:
val delegate: BridgeDelegate<HotwireDestination>
If I change private val delegate to delegate then I get the following error:
e: file:///app/src/main/java/com/masilotti/hikingjournal/components/ButtonComponent.kt:14:17 Cannot access 'val delegate: BridgeDelegate<HotwireDestination>':
it is private/*private to this*/ in 'com/masilotti/hikingjournal/components/ButtonComponent'.
I'm extra confused because if I copy paste this into a brand new Hotwire Native app I don't get the error. Same goes for the demo app.
Any ideas what could be causing this? I'm at a loss as to what I could have configured, or dependency I added, to change something so fundamental about Kotlin. I'm using Hotwire Native Android v1.1.1.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with app/src/main/java/com/masilotti/hikingjournal/components/ButtonComponent.kt and the Bridge Components guide, then compare the BridgeComponent and BridgeDelegate APIs used by version 1.1.1 with the demo and a newly generated app. Reproduce the compilation errors and identify the dependency or API difference that makes the documented component compile consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100