-
Notifications
You must be signed in to change notification settings - Fork 78
Describe issue with using compiler plugin in lambdas with DslMarker receivers #1669
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
bc5604b
Avoid unnecessary recompositions
koperagen 0ee17db
Fix Android example IDE import
koperagen 0295640
Fix DataFrameTable header overlap with rows in preview
koperagen b5848a0
Describe issue with using compiler plugin in lambdas with DslMarker r…
koperagen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
docs/StardustDocs/topics/compilerPluginLimitationsAndWorkarounds.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| # Known limitations and workarounds | ||
|
|
||
| ### Compiler plugin in lambdas with receiver marked as DslMarker | ||
|
|
||
| Problem: Property calls on a dataframe type created inside @Composable `Column { }` lambda cannot be resolved. | ||
| [Issue 1604](https://github.com/Kotlin/dataframe/issues/1604) | ||
|
|
||
| The lambda of `Column` has a receiver parameter `content: @Composable ColumnScope.() -> Unit`. | ||
|
|
||
| Here's the declaration from Compose. Receiver parameter types with annotations similar to this one will conflict with the plugin. | ||
| ```kotlin | ||
| @LayoutScopeMarker | ||
| interface ColumnScope | ||
|
|
||
| @DslMarker | ||
| annotation class LayoutScopeMarker | ||
| ``` | ||
|
|
||
| Repro: The snippet below shows a dataframe variable initialized with a local DataFrame type inside a `Column` lambda. `ageComposableLambdaScope` cannot be resolved. | ||
|
|
||
| ```kotlin | ||
| @DataSchema | ||
| data class Person(val age: Int, val name: String) | ||
|
|
||
| @Composable | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be clearer if you split this example because it now contains the bug and the solution interwoven with each other. I'd first write the reproducer containing the bug, then separately write the workaround, so it's easy to see the difference. |
||
| fun DataFrameScreen(df: DataFrame<Person>) { | ||
| Column { | ||
| val filteredDf = remember(df) { | ||
| df | ||
| .add("ageComposableLambdaScope") { age } | ||
| .filter { ageComposableLambdaScope >= 20 } | ||
| } | ||
| filteredDf.ageComposableLambdaScope // error | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| Error message: | ||
| ``` | ||
| val ColumnsScope<Person_59I>.ageComposableLambdaScope: Int' | ||
| cannot be called in this context with an implicit receiver. | ||
| Use an explicit receiver if necessary | ||
| ``` | ||
|
|
||
| Workaround: | ||
| Initialize your dataframe properties outside lambdas with DslMarker receiver parameters. | ||
|
|
||
| ```kotlin | ||
| @DataSchema | ||
| data class Person(val age: Int, val name: String) | ||
|
|
||
| @Composable | ||
| fun DataFrameScreen(df: DataFrame<Person>) { | ||
| val filteredDf = remember(df) { | ||
| df | ||
| .add("ageValidScope") { age } | ||
| .filter { ageValidScope >= 20 } | ||
| } | ||
| filteredDf.ageValidScope // OK | ||
|
|
||
| Column { | ||
| Text(filteredDf.ageValidScope.toString()) | ||
| } | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| [versions] | ||
| agp = "9.0.0-beta04" | ||
| agp = "9.0.0" | ||
| kotlin = "2.3.0-RC2" | ||
| coreKtx = "1.10.1" | ||
| junit = "4.13.2" | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.