Skip to content

Instantly share code, notes, and snippets.

@ikolomiets
Created January 2, 2022 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikolomiets/689519a10f6f0a289a2ab2c06df710c1 to your computer and use it in GitHub Desktop.
Save ikolomiets/689519a10f6f0a289a2ab2c06df710c1 to your computer and use it in GitHub Desktop.
Demo of "This function has a reified type parameter and thus can only be inlined at compilation time, not called directly" Ktor error
@Serializable
data class Age(val value: Int)
@Serializable
data class Update<T>(val old: T, val new: T)
fun main() {
embeddedServer(Netty, port = 8080) {
install(ContentNegotiation) {
json()
}
routing {
update<Age>()
}
}.start(wait = true)
}
inline fun <reified T> Route.update() {
post("/") {
val update = call.receive<Update<T>>()
application.log.info("XXX update={}", update)
call.respond(HttpStatusCode.OK, "OK")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment