Skip to content

Conversation

@skydoves
Copy link
Owner

@skydoves skydoves commented Nov 3, 2025

Inference logics for Parcelable classes. (#3)

Summary by CodeRabbit

  • Bug Fixes

    • Fixed false positive warnings for @parcelize data classes.
  • Improvements

    • @Parcelize-annotated classes with stable properties are now correctly identified as STABLE, improving stability detection accuracy.

@skydoves skydoves self-assigned this Nov 3, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

Walkthrough

Added support for analyzing @Parcelize-annotated classes in the Compose stability analyzer. The analysis now detects Parcelize data classes, checks their declared properties, marks them as UNSTABLE if any are mutable (var), and returns STABLE if all properties are immutable and stable. This check prioritizes Parcelize analysis before interface-related logic.

Changes

Cohort / File(s) Summary
Documentation
compose-stability-analyzer-idea/CHANGELOG.md
Added changelog entries documenting the fix for false positives on @parcelize data classes and the improvement for correctly identifying @Parcelize-annotated classes with stable properties as STABLE.
@parcelize Analysis — IDE Plugin
compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt
Introduced pre-check logic for @Parcelize-annotated classes before INTERFACE handling: detects Parcelize data classes, returns UNSTABLE if any property is var, returns STABLE if all properties are val and stable. Updated inline documentation and section numbering.
@parcelize Analysis — Compiler Plugin
stability-compiler/src/main/kotlin/com/skydoves/compose/stability/compiler/lower/StabilityAnalyzerTransformer.kt
Replaced the 14th stability analysis step to analyze @parcelize classes before interface checks. Inspects declared properties, returns UNSTABLE for any var properties, derives stability from property types otherwise. Updated documentation comments and numbering.

Sequence Diagram

sequenceDiagram
    participant Analyzer
    participant Class
    
    rect rgb(230, 245, 255)
    Note over Analyzer: New @Parcelize Check
    Analyzer->>Class: Is @Parcelize-annotated?
    
    alt Yes, is data class
        Analyzer->>Class: Check declared properties
        
        alt Any var (mutable) properties?
            Analyzer-->>Analyzer: Return UNSTABLE<br/>("Has mutable properties")
        else All properties are val
            Analyzer->>Class: Analyze property stability
            
            alt All properties STABLE
                Analyzer-->>Analyzer: Return STABLE<br/>("@Parcelize with stable properties")
            else Any property UNSTABLE or MIXED
                Analyzer-->>Analyzer: Fall through to next checks<br/>(Interfaces, Abstract, Regular)
            end
        end
    else Not @Parcelize or not data class
        Analyzer-->>Analyzer: Skip to Interface checks
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Key areas requiring attention during review:

  • Verify that the @parcelize property analysis correctly distinguishes between var (mutable) and val (immutable) properties
  • Confirm that the stability propagation logic for @parcelize properties matches the existing stability inference patterns
  • Ensure the reordering of analysis steps (moving @parcelize before INTERFACE checks) doesn't inadvertently affect other class type handling or create analysis conflicts
  • Check that both IDE plugin (KtStabilityInferencer.kt) and compiler plugin (StabilityAnalyzerTransformer.kt) implementations are consistent

Poem

🐰 Hoppy news from the stability warren!

Parcelize classes now hold their ground,
With stable val properties, we're safely bound,
Mutable vars send rabbits fleeing fast,
The checks run first—a feature built to last!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is minimal and lacks the required structure from the template. While it briefly mentions the subject (Inference logics for Parcelable classes) and references issue #3, it is missing critical sections including the Goal, Implementation details, Explain examples, and instructions for running spotlessApply and apiDump checks. The description does not provide sufficient detail for maintainers to understand the motivation, implementation approach, or testing performed. Expand the pull request description to follow the template structure. Add a 'Goal' section explaining why this change is needed and how it addresses issue #3, an 'Implementation details' section describing the changes made to handle Parcelize classes, and an 'Explain examples' section with code examples. Additionally, confirm that spotlessApply and apiDump checks have been run.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title 'Inference logics for Parcelable classes' is clear and directly related to the changeset. It accurately describes the primary focus of the changes, which involve adding stability inference logic for Parcelable/Parcelize-annotated classes across the compiler and IDE plugin code. The title is concise and specific enough to convey the main change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/stability-parcelable

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a0e9a5c and fc177b2.

📒 Files selected for processing (3)
  • compose-stability-analyzer-idea/CHANGELOG.md (1 hunks)
  • compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt (2 hunks)
  • stability-compiler/src/main/kotlin/com/skydoves/compose/stability/compiler/lower/StabilityAnalyzerTransformer.kt (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build IntelliJ Plugin
  • GitHub Check: Test IntelliJ Plugin
  • GitHub Check: Build and Tests
  • GitHub Check: API check
🔇 Additional comments (3)
compose-stability-analyzer-idea/CHANGELOG.md (1)

10-10: CHANGELOG entries are clear and well-formatted.

Both entries accurately document the Parcelize support feature. Line 10 correctly cites Issue #3, and line 18 clearly describes the improvement with specific reference to "stable properties," aligning with the inference logic described in the PR summary.

Also applies to: 18-18

compose-stability-analyzer-idea/src/main/kotlin/com/skydoves/compose/stability/idea/k2/KtStabilityInferencer.kt (1)

51-55: Documentation updated correctly.

The inline documentation accurately reflects the new Parcelize-based analysis step and the renumbered subsequent steps.

stability-compiler/src/main/kotlin/com/skydoves/compose/stability/compiler/lower/StabilityAnalyzerTransformer.kt (1)

237-241: Documentation updated correctly.

The analysis order documentation accurately reflects the new Parcelize handling at step 14 and the renumbered subsequent steps.

@skydoves skydoves merged commit 6eaf826 into main Nov 3, 2025
13 checks passed
@skydoves skydoves deleted the fix/stability-parcelable branch November 3, 2025 18:56
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

Successfully merging this pull request may close these issues.

2 participants