Hey, i'm experimenting with Arrow Analysis, and I noticed something. I think I kinda guess why this works like this, but thought it would be interesting to share:
I was trying to see how far I can take Arrow Analysis and I was writing a Spring Boot application and tried to see what happened if I used this as a
PathVariable
@RestController
class MyController {
@JvmInline
value class Positive(val value: Int) {
init { require(value > 0) }
operator fun plus(other : Positive) = Positive(this.value + other.value)
}
@GetMapping("/{id}")
fun getTypeWithId(@PathVariable("id") id : Positive) : ResponseEntity<Positive>{
println(id)
return ResponseEntity.ok(id)
}
}
Turns out, if I send a request with the value
-1
it will actually print and return
-1
, so I just managed to create a Positive negative value 😄
So it compiles, and it seems that jackson is ignoring the
require
when creating a value class. (I am aware that this is not Arrows fault, just wanted to share)