varArg properties breaks when using most types.
See original GitHub issue- I have searched existing issues and this is not a duplicate
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
- Create either LayoutSpec or MountSpec.
- Add
@Prop(varArg = "name") names : List<String>
as a property. - Code should compile fine here.
- Change types to something else outside of basic types (IE: Color, TextView, etc)
- 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:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should work fine in Java, but I can take a look and fix it for Kotlin code! cc: @passy
@kjbilliot Fix has been merged into
master
, will probably be part of release0.16.0
😃