Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StaticScreen codegen broken for kotlinInject/kotlinInjectAnvil #1704

Open
wiyarmir opened this issue Oct 4, 2024 · 3 comments
Open

StaticScreen codegen broken for kotlinInject/kotlinInjectAnvil #1704

wiyarmir opened this issue Oct 4, 2024 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@wiyarmir
Copy link

wiyarmir commented Oct 4, 2024

Having a screen such as

@Parcelize
data object Static : StaticScreen

@CircuitInject(Static::class, AppScope::class)
@Composable
fun StaticUi(screen: Static, modifier: Modifier) {} 

generates

@Inject
@ContributesBinding(
  AppScope::class,
  multibinding = true,
)
public class StaticUiFactory : Ui.Factory {
  override fun create(screen: Screen, context: CircuitContext): Ui<*>? = when (screen) {
    Static -> ui<CircuitUiState> { _, modifier -> StaticUi(modifier = modifier, screen) }
    else -> null
  }
}

which is invalid because it mixes named and positional arguments

setup: no multiplatform, single module

kotlinInject = "0.7.2"
kotlinInjectAnvil = "0.0.4"
circuit = "0.24.0"
@wiyarmir
Copy link
Author

wiyarmir commented Oct 4, 2024

I've tried quickly adding Screen to the known parameters in the FactoryType.UI case in computeFactoryData() but I didn't understand the impact of modifying KSFunctionDeclaration.assistedParameters(...) so it doesn't generate it twice

@ZacSweers
Copy link
Collaborator

I think we should make this not generate invalid code, but out of curiosity - why do you need the object passed as a param given its singleton nature?

@wiyarmir
Copy link
Author

wiyarmir commented Oct 8, 2024 via email

@ZacSweers ZacSweers added the bug Something isn't working label Oct 23, 2024
@ZacSweers ZacSweers added this to the 1.0.0 milestone Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants