mapbox-maps-android
mapbox-maps-android copied to clipboard
Wrong IncorrectNumberOfArgumentsInExpression in match-expression
Environment
- Android OS version: No matter
- Devices affected: No matter
- Maps SDK Version: 11.1.0
Observed behavior and steps to reproduce
I get lint error IncorrectNumberOfArgumentsInExpression "Incorrect number of expressions within match Expression: expected an even number, but 5 was found." in this code:
enum class Type(@ColorInt val color: Int) {
RED(Color.RED),
GREEN(Color.GREEN),
BLUE(Color.BLUE);
}
fun Expression.ExpressionBuilder.getColor(type: Type) {
stop {
literal(type.name)
color(type.color)
}
}
...
// there is IncorrectNumberOfArgumentsInExpression
lineColor(
match {
get("type")
getColor(Type.RED)
getColor(Type.GREEN)
getColor(Type.BLUE)
color(Color.BLACK)
}
)
This code does not have an error:
lineColor(
match {
get("type")
stop {
literal(Type.RED.name)
color(Type.RED.color)
}
stop {
literal(Type.GREEN.name)
color(Type.GREEN.color)
}
stop {
literal(Type.BLUE.name)
color(Type.BLUE.color)
}
color(Color.BLACK)
}
)
Expected behavior
No lint error IncorrectNumberOfArgumentsInExpression
Notes / preliminary analysis
Additional links and references
example code https://github.com/Copatych/MapboxBugs/blob/IncorrectNumberOfArgumentsInExpression_bug/app/src/main/java/com/example/mapboxbugs/MainActivity.kt
Same here