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

False Positive Reusing Modifier in Composable when inner composable parameters have the same name #292

Closed
simtse opened this issue Mar 4, 2024 · 1 comment

Comments

@simtse
Copy link

simtse commented Mar 4, 2024

Got a false positive because the modifier from the Circuit UI composable's had the same name as another nested Composable higher order function that also provided a Modifier that was named modifier. To Android Studio, the inner modifier wasn't a problem and wasn't referencing the outer TestScreenUi modifier.

@CircuitInject(TestScreen::class, UserScope::class)
@Composable
fun TestScreenUi(state: TestScreen.State, modifier: Modifier = Modifier) {
  Scaffold(
    modifier = modifier,
    topBar = {
      SKTopAppBar(
        ...
      )
    },
  ) { paddingValues ->
    SKList(
      ...
      customView = { vm, modifier ->
        when (vm.customViewType) {
          VIEW_TYPE_MY_CUSTOM -> {
            MyCustomRow(viewModel = vm, modifier = modifier)
          }
          ...
        }
      }
    )
  }
}

If I changed to the following, the error would disappear.

@CircuitInject(TestScreen::class, UserScope::class)
@Composable
fun TestScreenUi(state: TestScreen.State, modifier: Modifier = Modifier) {
  Scaffold(
    modifier = modifier,
    topBar = {
      SKTopAppBar(
        ...
      )
    },
  ) { paddingValues ->
    SKList(
      ...
      customView = { vm, rowModifier -> // <---- Here to rowModifier
        when (vm.customViewType) {
          VIEW_TYPE_MY_CUSTOM -> {
            MyCustomRow(viewModel = vm, modifier = rowModifier). // <---- Here to rowModifier
          }
          ...
        }
      }
    )
  }
}
@ZacSweers
Copy link
Collaborator

Duplicate of #268. In short, you should avoid name shadowing anyway

@ZacSweers ZacSweers closed this as not planned Won't fix, can't repro, duplicate, stale Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants