question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

varArg properties breaks when using most types.

See original GitHub issue

Version

Config.Dependencies.litho is "0.14.0"

    implementation("com.facebook.litho", "litho-core", Config.Dependencies.litho)
    implementation("com.facebook.litho", "litho-widget", Config.Dependencies.litho)
    compileOnly("com.facebook.litho", "litho-annotations", Config.Dependencies.litho)
    kapt("com.facebook.litho", "litho-annotations", Config.Dependencies.litho)
    kapt("com.facebook.litho", "litho-processor", Config.Dependencies.litho)

Issues and Steps to Reproduce

  1. Create either LayoutSpec or MountSpec.
  2. Add @Prop(varArg = "name") names : List<String> as a property.
  3. Code should compile fine here.
  4. Change types to something else outside of basic types (IE: Color, TextView, etc)
  5. Code will no longer compile, giving the following two errors in the build panel, from the generated component .java file. error: illegal start of type public Builder color(@NotNull) ? extends Color color) { error: ';' expected public Builder color(@NotNull) ? extends Color color) {

Expected Behavior

Code should compile fine, and I should be able to use the component in the way demonstrated in the documentation for whatever type I’d need to be a varArg.

Link to Code

Example code in Kotlin.

@LayoutSpec
object TestComponentSpec {
    @OnCreateLayout
    fun onCreateLayout(
        c : ComponentContext,
        @Prop(varArg = "color") colors : List<Color>
    ) : Component {
        return Row.create(c).build()
    }
}

Errors from Gradle:

e: /home/<snip>/android/app/build/generated/source/kapt/devDebug/com/mingo/chat/ui/TestComponent.java:130: error: illegal start of type
    public Builder color(@NotNull ? extends Color color) {
                                  ^
e: /home/<snip>/android/app/build/generated/source/kapt/devDebug/com/mingo/chat/ui/TestComponent.java:130: error: ')' expected
    public Builder color(@NotNull ? extends Color color) {
                                   ^
e: /home/<snip>/android/app/build/generated/source/kapt/devDebug/com/mingo/chat/ui/TestComponent.java:130: error: ';' expected
    public Builder color(@NotNull ? extends Color color) {
                                           ^
e: /home/<snip>/android/app/build/generated/source/kapt/devDebug/com/mingo/chat/ui/TestComponent.java:130: error: <identifier> expected
    public Builder color(@NotNull ? extends Color color) {
                                                       ^

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
pavlosptcommented, May 25, 2018

This should work fine in Java, but I can take a look and fix it for Kotlin code! cc: @passy

1reaction
pavlosptcommented, May 31, 2018

@kjbilliot Fix has been merged into master, will probably be part of release 0.16.0 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why do I get a compilation warning here (var args method call ...
The casts to Object and Object[] did not work out for me, it broke my code, resulting in "Encountered array-valued parameter binding, but...
Read more >
How varargs works in Java Explained with Examples - eduCBA
The first way is by overloading, and the second way is by using the array arg-argument. There will be only one type of...
Read more >
Vararg method arguments should not be confusing
Loops should not contain more than a single "break" or "continue" statement. Code Smell ... Classes should not be coupled to too many...
Read more >
Fixing ugly Java APIs: read-only generic varargs
This is forbidden because Java arrays are covariant and they check the type of values written to them at runtime. But at runtime,...
Read more >
Documentation - TypeScript 4.0
Variadic Tuple Types. Consider a function in JavaScript called concat that takes two array or tuple types and concatenates them together to make...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found