https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
squarelibraries
  • s

    Sean Proctor

    10/12/2022, 7:46 AM
    I updated from 1.5.4 to 2.0.0-alpha04 and the JVM version works as expected. I guess there's a bug in 1.5.4.
  • p

    Pablichjenkov

    10/12/2022, 10:26 AM
    Hi there, Quick one in regards to dagger-hilt. I am getting a build exception when using @HiltViewModel annotation. This is the link to SO: https://stackoverflow.com/questions/73931588/injection-of-an-hiltviewmodel-class-is-prohibited-since-it-does-not-create-a-vi
    • 1
    • 2
  • m

    Marc Plano-Lesay

    10/18/2022, 12:25 AM
    It seems that Barber only supports rendering Strings, which is fair enough - does it have support for conditionals? If not, is it something that might be planned? Having a boolean field in my
    DocumentData
    doesn't seem to make it happy at all.
  • j

    jessewilson

    10/18/2022, 3:54 AM
    Just strings. Is that really two different documents?
  • m

    Marc Plano-Lesay

    10/18/2022, 3:59 AM
    Not two documents, rather, omitting or displaying something in the body of that single document
  • m

    Marc Plano-Lesay

    10/18/2022, 4:02 AM
    I'm generating font definition files, with a bunch of entries looking like this:
    FontFace={ul}{n}{*-Thin},
      FontFace={ul}{it}{*-ThinItalic},
      FontFace={xl}{n}{*-ExtraLight},
    Not every font has every weight (thin, extra light...) or shape (regular/italic) combination, so I'd like to do something like this:
    {{#hasThin}}FontFace={ul}{n}{*-Thin},{{/hasThin}}
      {{#hasThinItalic}}FontFace={ul}{it}{*-ThinItalic},{{/hasThinItalic}}
      {{#hasExtraLight}}FontFace={xl}{n}{*-ExtraLight},{{/hasExtraLight}}
  • a

    Andrew Alexander

    10/18/2022, 8:17 PM
    Barber uses regular Mustache under the hood so standard Mustache conditionals as you put are supported.
  • p

    Patrik Åkerfeldt

    10/19/2022, 7:12 AM
    Maybe a bit of tangent for this channel but I'm using kotlinpoet to generate source code for a library I'm building. The library communicates with a service and the protocol is defined in a json file which I use to generate sources (request types, event types, enums, etc). However, I run into a circular dependency problem where the generated sources depends on the regular sources (e.g. implementing interfaces), but the regular sources would also benefit from depending on the generated sources (e.g. access to error codes enum, access to event types for deserialization). How can this typically be resolved? I don't have much past experience with generating sources like this. Atm, I'm relying on reflection in some few cases to deal with this problem but it's not particularly nice. Another approach would be to, instead of genering sources at compile time, generate sources on-demand and store them together with the regular source files. Would also mean that I'd have to check those into git.
  • t

    TheOnlyTails

    10/19/2022, 4:06 PM
    How do I add a parameter to the constructor of a super interface?
    addSuperclassConstructorParameter
    doesn't seem to do anything
    e
    • 2
    • 4
  • d

    doubov

    10/20/2022, 6:28 PM
    In Sqldelight 2.0.0, did anything change about the way migrations are run? For tests, we setup a sqlite tokenizing driver with
    afterEvaluate {
            tasks.withType<VerifyMigrationTask>().configureEach {
                doFirst {
                    TokenizingDriver(this.project).replaceJDBCDriver()
                }
            }
        }
    This works fine pre-2.0.0, but now it throws the following exception:
    > There was a failure while executing work items
       > A failure occurred while executing app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction
          > Error compiling Error compiling CREATE VIRTUAL TABLE SearchText USING fts5(
                term,
                type UNINDEXED,
                sourceUid UNINDEXED,
                referredItemUid UNINDEXED,
                prefix = '2 3 4 5 6 7 8 9 10',
                tokenize = 'unicode61_synonym'
            )
    Adding a logger to
    DriverManager
    provides us with the following Stacktrace:
    org.sqlite.SQLiteException: [SQLITE_ERROR] SQL error or missing database (no such tokenizer: unicode61_synonym)
            at org.sqlite.core.DB.newSQLException(DB.java:1135)
            at org.sqlite.core.DB.newSQLException(DB.java:1146)
            at org.sqlite.core.DB.execute(DB.java:944)
            at org.sqlite.jdbc3.JDBC3PreparedStatement.lambda$execute$0(JDBC3PreparedStatement.java:56)
            at org.sqlite.jdbc3.JDBC3Statement.withConnectionTimeout(JDBC3Statement.java:429)
            at org.sqlite.jdbc3.JDBC3PreparedStatement.execute(JDBC3PreparedStatement.java:51)
            at app.cash.sqlite.migrations.CatalogDatabase$Companion.init(CatalogDatabase.kt:52)
            at app.cash.sqlite.migrations.CatalogDatabase$Companion.fromFile(CatalogDatabase.kt:36)
            at app.cash.sqlite.migrations.CatalogDatabase$Companion.withInitStatements(CatalogDatabase.kt:32)
            at app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction.createCurrentDb(VerifyMigrationTask.kt:146)
            at app.cash.sqldelight.gradle.VerifyMigrationTask$VerifyMigrationAction.execute(VerifyMigrationTask.kt:119)
            at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
  • z

    Zach

    10/25/2022, 6:17 PM
    Using Paparazzi, is there some trick to get it to render the entirety of a
    LazyColumn
    without just setting the
    ScreenHeight
    to some arbitrarily large number? I have attempted to use
    V_SCROLL
    and
    FULL_EXPAND
    and neither seem to change anything. Additionally, the list it is rendering is immutable.
    y
    • 2
    • 2
  • a

    Aditya Kurkure

    10/26/2022, 5:33 AM
    I tried the Zipline WorldClock Sample recently. When I tried to just make code changes to the server they were reflected on the app even when the app was open. I found this interesting, I thought that zipline would download the js code once when we call
    zipline.take
    and would cache that till the next call to
    zipline.take
    . Does the client poll the zipline server? (or some other way the server pushes data to the client like in grpc). Is there a way to ensure that even if the file is changed we don't make changes on the client side if the client is in the middle of a flow using zipline? Consider that the user is in the middle of a payment flow and we make changes to the js file it could it not lead to some unexpected behaviour?
    j
    • 2
    • 2
  • k

    KamilH

    10/26/2022, 3:02 PM
    I would like to select all possible values when empty list/null is passed to function or filtered values when selected filters are passed to the function. Recently I went through #1719 and it works great for single “id”:
    WHERE (season = :season OR :season IS NULL)
    Is it possible to achieve the same for collection of “ids” (with
    IN
    operator)? The following code doesn’t work, because it generates expected type as
    Collection<Season?>
    instead of
    Collection<Season>?
    and generally it’s not handled properly
    WHERE (season IN :season OR :season IS NULL)
    To overcome this issue I use the following statement:
    WHERE CASE WHEN :seasonIsEmpty THEN TRUE ELSE season IN :season END
    and it works great. However it forces me to introduce additional variable (
    seasonIsEmpty
    ) which seems not optimal. I would expect that at least the following code should work:
    WHERE CASE WHEN :season IS NULL THEN TRUE ELSE season IN :season END
    but it also generates
    Collection<Season?>
    instead of
    Collection<Season>?
    Is there a way to simplify this statement?
    d
    • 2
    • 1
  • j

    jannis

    10/28/2022, 3:10 PM
    What would be a good approach to run/verify paparazzi tests on my CI System? I always have normal non-paparazzi unit tests and paparazzi screenshot tests within the same module. Let's assume I have a gradle module,
    sample
    : •
    ./gradlew sample:verifyPaparazziDebug
    would invoke the paparazzi tests as well as the other JUnit Tests. But I'd have to list all my modules in the project individually. •
    ./gradlew sample:testDebug
    (or something like
    ./gradlew testDebugUnitTest
    for the whole project) would run all the paparazzi tests as well as the other JUnit Tests, but it would not check if anything has changed (hence not fail). Is there any way to separate those two test groups? Does this even make sense? Or can I run everything (including the verification) in an easy way?
  • s

    saket

    10/28/2022, 3:17 PM
    I think you're looking for the
    check
    task
  • j

    Javier

    10/28/2022, 3:20 PM
    ./gradlew verifyPaparazziDebug
    will run that task in all projects
  • j

    Javier

    10/28/2022, 3:21 PM
    you can use
    ./gradlew verifyPaparazziDebug testDebug
    too, if you want only to run tests. If you want to run all checks, then
    ./gradlew check
  • j

    jannis

    10/28/2022, 3:26 PM
    I think
    check
    might also run different stuff (like linting), correct? I think I've tried
    verifyPaparazziDebug
    but it did nothing, since I didn't change anything in the source code 🙄 So I guess it was just cached.
    j
    • 2
    • 6
  • j

    jannis

    10/28/2022, 3:26 PM
    I think this should work - thank you so much ❤️
  • r

    Ruben Quadros

    10/31/2022, 9:26 AM
    Hi everyone, I'm using retrofit and I have the following question: Will retrofit able to parse one field of the response as generic? More details in the 🧵
    a
    • 2
    • 6
  • p

    Patrik Åkerfeldt

    10/31/2022, 9:43 AM
    Have a question on kotlinpoet or source code generation in general. I have a library project which generates sources. The code that generates sources depends on the regular sources. This can be solved by requiring the code generation to run after
    compileKotlin
    . However, this means that after first compilation of the project there aren't any compiled classes for the generated sources. I have a circular dependency where I can't run source code generation until classes are compiled but I also want the compile phase to include the generated sources. How to best deal with this? To me it would make sense if I could first compile specified classes needed to run the code generation, then run source code generation and lastly run the "regular"
    compileKotlin
    .
    c
    • 2
    • 2
  • a

    Aaron Todd

    10/31/2022, 4:10 PM
    Is there a way to set HTTP trailers for a request in okhttp?
  • j

    jw

    10/31/2022, 4:12 PM
    the OkHttp website is super broken, but https://square.github.io/okhttp/4.x/okhttp/okhttp3/-response/-builder/trailers/
  • a

    Aaron Todd

    10/31/2022, 4:12 PM
    Thanks Jake, that's on the response side though. Is there a way to set request trailers?
  • j

    jw

    10/31/2022, 4:18 PM
    oh you're right. i assumed it was symmetric so only did a quick search. i only remember the PR land and again assumed it was symmetric.
    a
    • 2
    • 1
  • y

    yschimke

    10/31/2022, 4:31 PM
    I believe docs will be fixed on next release...
  • d

    Dorit Rein

    10/31/2022, 9:01 PM
    Hey all! I'm seeing this error when I try to upgrade to Kotlin 1.7.2:
    e: java.lang.NoSuchMethodError: 'org.jetbrains.kotlin.ir.declarations.IrModuleFragment org.jetbrains.kotlin.ir.declarations.IrModuleFragment.transform(org.jetbrains.kotlin.ir.visitors.IrElementTransformer, java.lang.Object)'
            at com.squareup.anvil.compiler.ModuleMergerIr.generate(ModuleMergerIr.kt:41)
            at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$lambda-1(JvmIrCodegenFactory.kt:121)
            at org.jetbrains.kotlin.psi2ir.Psi2IrTranslator.generateModuleFragment(Psi2IrTranslator.kt:88)
            at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr(JvmIrCodegenFactory.kt:146)
            at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.convertToIr$default(JvmIrCodegenFactory.kt:64)
            at org.jetbrains.kotlin.backend.jvm.JvmIrCodegenFactory.generateModule(JvmIrCodegenFactory.kt:59)
            at org.jetbrains.kotlin.codegen.KotlinCodegenFacade.compileCorrectFiles(KotlinCodegenFacade.java:35)
            at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.generate(KotlinToJVMBytecodeCompiler.kt:331)
            at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:123)
            at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli$default(KotlinToJVMBytecodeCompiler.kt:58)
            at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
            at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
            at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:92)
            at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:44)
            at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:98)
            at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1618)
            at jdk.internal.reflect.GeneratedMethodAccessor108.invoke(Unknown Source)
            at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
            at java.base/java.lang.reflect.Method.invoke(Method.java:566)
            at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
            at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
            at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
            at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
            at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
            at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
            at java.base/java.security.AccessController.doPrivileged(Native Method)
            at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
            at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
            at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
            at java.base/java.lang.Thread.run(Thread.java:829)
    this only happens sporadically on some gradle targets. Running Kotlin 1.7.20, Anvil 2.4.2, dagger - 2.38.1. Double checked that if I remove the anvil plugin from the target, it'll compile just fine.
  • r

    ralf

    10/31/2022, 9:56 PM
    The bump to Kotlin 1.7.20 hasn’t been published yet https://github.com/square/anvil/pull/643 It seems like there’s a binary incompatibility in the Kotlin compiler. I suggest using the latest snapshot.
  • a

    Aaron Todd

    11/01/2022, 1:33 PM
    Multiplatform (coroutines) okio/okhttp question... A strong case is made for the blocking I/O model in the comment thread of this okio issue. The main argument being that dispatching once to
    <http://Dispatchers.IO|Dispatchers.IO>
    at the appropriate level to do your blocking read/write will be the most efficient. When we benchmarked using
    suspend
    for low level JSON tokenization in the AWS SDK for Kotlin we found this to hold true.
    suspend
    at too low a level (inner loops, small byte reads, etc) causes significant performance degradation. My question then is what about JS (node) support? The recommendation to block a thread is fine for JVM/Native, what would the equivalent be for JS?
  • j

    jw

    11/01/2022, 1:38 PM
    In the one place I use it I buffer the whole body before wrapping
Powered by Linen
Title
j

jw

11/01/2022, 1:38 PM
In the one place I use it I buffer the whole body before wrapping
View count: 7