Skip to content

Issue 4 - Single child composable problem #7

@aballano

Description

@aballano

Android Studio Build:

Android Studio 4.0 Canary 8
Build #AI-193.5233.102.40.6107147, built on January 2, 2020
Runtime version: 1.8.0_212-release-1586-b4-5784211 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
macOS 10.14.6
GC: ParNew, ConcurrentMarkSweep
Memory: 4012M
Cores: 12
Registry: ide.new.welcome.screen.force=true, ide.balloon.shadow.size=0
Non-Bundled Plugins: com.chrisrm.idea.MaterialThemeUI, com.squareup.sqldelight

Version of Gradle Plugin:

4.0.0-alpha08

Version of Gradle:

gradle-6.1-rc-1-all

Version of Java:

1.8

OS:

MacOs Mojave 10.14.6

Steps to Reproduce:

  • Create a simple button with more than one components inside:
  • Build the app

Expected result:

  • Any component that can only have 1 child inside should explicitly mark it this way, so adding multiple components should give a compile error

Actual result:

  • No errors, only first component is rendered.

Proposed solution:

  • The Composable annotation could contain a parameter to specify an arbitrary arity that would be enforced at compile time by the compiler plugin itself.

Sample branch:
https://github.com/arrow-kt/compose-samples/blob/gotchas/gist4/JetNews/app/src/main/java/com/example/jetnews/MainActivity.kt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions