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
announcements
  • s

    serebit

    08/16/2020, 6:15 AM
    Finally got all my software updated to Kotlin 1.4.0 since most of the artifacts have been published! Still waiting on Ktor though, guess that'll have to wait until Monday
    s
    n
    j
    • 4
    • 10
  • a

    andylamax

    08/16/2020, 1:34 PM
    I am trying to use kotlin/jvm with neo4j and I end getting
    MalformedClass Name
    Why is this?
    s
    n
    • 3
    • 4
  • b

    Big Chungus

    08/16/2020, 7:53 PM
    Wouldn't be surprised if this was asked already, but are there any plans for official vscode kotlin extension? I think this would help a ton with kotlin adaptation on the web and as a scripting language
    r
    l
    m
    • 4
    • 8
  • l

    luke

    08/16/2020, 9:36 PM
    Could anyone with experience with Kotlix Serialization take a look here and tell me why I can't deserialize all
    null
    Int
    as
    0
    ? https://gitpod.io/#snapshot/eee0ffb1-3cd0-428c-b59a-1b314243ecc6
    • 1
    • 1
  • u

    ursus

    08/17/2020, 3:40 AM
    (obviously S is generic)
    m
    • 2
    • 2
  • l

    Luis Daivid

    08/17/2020, 9:43 AM
    I have one question. I recently read [“Null is your friend, not a mistake”](https://medium.com/@elizarov/null-is-your-friend-not-a-mistake-b63ff1751dd5) by Roman Elizarov. So I found out that I shouldn’t avoid null, I should use it properly. And that is philosophy of Kotlin. If so, Why is there no
    indexOfOrNull
    function in Kotlin? According to Roman Elizarov, Null is the cleanest and most obvious way to indicate that there is no value. But There is only
    indexOf
    function that return -1 in kotlin.
    m
    d
    +2
    • 5
    • 7
  • a

    andylamax

    08/17/2020, 10:39 AM
    Does the kotlin plugin
    no-arg
    work with kotlin multiplatform? I have this
    gradle
    configuration
    plugins {
        kotlin("multiplatform")
        kotlin("plugin.noarg")
    }
    
    noArg {
        annotations("kotlinx.serialization.Serializable","org.neo4j.ogm.annotation.NodeEntity")
    //    annotation("org.neo4j.ogm.annotation.NodeEntity")
    }
    I also have this class
    @Serializable
    @NodeEntity
    open class UserAccount(
        @Id
        @GeneratedValue
        override var id: Long? = null,
        override var uid: String = "",
        val name: String,
        val permits: List<String> = listOf(),
        override var deleted: Boolean = false
    ) : Neo4JEntity
    But after compilation, I get this compiled JavaCode
    @kotlinx.serialization.Serializable @org.neo4j.ogm.annotation.NodeEntity public open class UserAccount public constructor(id: kotlin.Long? /* = compiled code */, uid: kotlin.String /* = compiled code */, name: kotlin.String, permits: kotlin.collections.List<kotlin.String> /* = compiled code */, deleted: kotlin.Boolean /* = compiled code */) : tz.co.asoft.Neo4JEntity {
        public companion object {
        }
    
        @kotlin.Deprecated public constructor(seen1: <http://kotlin.Int|kotlin.Int>, id: kotlin.Long?, uid: kotlin.String?, name: kotlin.String?, permits: kotlin.collections.List<kotlin.String>?, deleted: kotlin.Boolean, serializationConstructorMarker: kotlinx.serialization.SerializationConstructorMarker?) { /* compiled code */ }
    
        public open var deleted: kotlin.Boolean /* compiled code */
    
        @field:org.neo4j.ogm.annotation.Id @field:org.neo4j.ogm.annotation.GeneratedValue public open var id: kotlin.Long? /* compiled code */
    
        public final val name: kotlin.String /* compiled code */
    
        public final val permits: kotlin.collections.List<kotlin.String> /* compiled code */
    
        public open var uid: kotlin.String /* compiled code */
    
        public final fun ref(): tz.co.asoft.UserAccountRef { /* compiled code */ }
    
        @kotlin.Deprecated public object `$serializer` : kotlinx.serialization.internal.GeneratedSerializer<tz.co.asoft.UserAccount> {
        }
    }
    As you can see, It surely has no a no argument constructor. How do I achieve this?
    b
    s
    • 3
    • 3
  • b

    Bob Glamm

    08/17/2020, 1:25 PM
    Uhhh... how do I create a Kotlin library that can be used as-is in Java that doesn't reference kotlin.jvm.Intrinsics?
    e
    • 2
    • 1
  • p

    poohbar

    08/17/2020, 1:45 PM
    is 1.4 out?
    d
    d
    m
    • 4
    • 7
  • l

    laith

    08/17/2020, 5:21 PM
    Hi all, I have saw news, blogs, job posts @ JetBrian says, that Jetpack Compose going to be ported to other platforms, is iOS one of these platforms and how far we are from having this production ready?
    f
    z
    j
    • 4
    • 6
  • j

    Joe

    08/17/2020, 5:30 PM
    (slightly prematurely) looking at 1.4, and seeing a new compiler warning I don't quite understand. In the following class: https://github.com/trib3/leakycauldron/blob/master/testing/src/test/kotlin/com/trib3/testing/db/DAOTestBaseTest.kt lines 30 and 48 both look like:
    var reached = false
    With 1.4, line 30 triggers the following warning, but line 48 does not:
    DAOTestBaseTest.kt: (30, 23) Variable 'reached' initializer is redundant
    I can fix by replacing with
    var reached: Boolean
    , but would like to understand why the 2 instances are being treated differently first.
    n
    • 2
    • 11
  • u

    user

    08/17/2020, 5:43 PM
    Kotlin 1.4 Released with a Focus on Quality and Performance You can read this blog post in other languages: 日本語, Français, 한국어, Español, Português, Русский, 简体中文 Today we’re releasing Kotlin 1.4.0! Over the past years, we’ve been working hard on making Kotlin a programming language that is fun, enjoyable, and productive to work with. To continue our pursuit of this goal with this version of […]
    :kotlin-flag: 13
    ✨ 3
    🎉 42
    c
    m
    +4
    • 6
    • 14
  • j

    jeggy

    08/17/2020, 6:09 PM
    Is it recommended to write contracts for my functions? I want to have this function
    inline fun measureTimeMillisWithContract(block: () -> Unit): Long {
        contract {
            callsInPlace(block, EXACTLY_ONCE)
        }
        val start = System.currentTimeMillis()
        block()
        return System.currentTimeMillis() - start
    }
    but as it requires me to add the
    @ExperimentalContracts
    annotation, I don't really feel good to use contracts.
    n
    e
    i
    • 4
    • 4
  • m

    Manuel Pérez Alcolea

    08/17/2020, 7:53 PM
    Kotlin `IntRange`s don't hold any values in memory by themselves, is that right? I'm asking because my experience tells me they should be lazy, yet they are not `Sequence`s, so it's possible to get one from with
    asSequence()
    instead. And something like a direct
    map
    gives you a list. But I would still assume a range object doesn't contain anything, simply because "it makes sense" in my head.
    >>> (0..4).asSequence()
    res0: kotlin.sequences.Sequence<kotlin.Int> = kotlin.collections.CollectionsKt___CollectionsKt$asSequence$$inlined$Sequence$1@7bafb922
    >>> (0..4).map { it * 2 }
    res1: kotlin.collections.List<kotlin.Int> = [0, 2, 4, 6, 8]
    So what's in an
    IntRange
    before applying anything? (no
    asSequence()
    ) for example
    val myRange = 0..4
    n
    n
    • 3
    • 14
  • r

    Rohen Giralt

    08/17/2020, 9:38 PM
    Can I just say that I'm still groaning about the fact the Kotlin Team decided to label a section "expect fun"?
    n
    c
    • 3
    • 2
  • s

    SrSouza

    08/18/2020, 1:54 AM
    Hi folks, any one getting this exception on Kotlin 1.4 ?
    java.lang.NoSuchMethodError: kotlin.jvm.internal.FunctionReferenceImpl.<init>(ILjava/lang/Class;Ljava/lang/String;Ljava/lang/String;I)V
    at line 62 ( in 1.3.72 was working )
    a
    p
    • 3
    • 3
  • s

    spierce7

    08/18/2020, 2:35 AM
    Does anyone know how difficult it would be to use Kotlin to create a standalone JVM application and ship it? I believe a few years ago the JVM added a way to ship your application so that it could run without requiring a JVM installed on the client machine. I've just never done it before.
    t
    b
    +3
    • 6
    • 42
  • l

    laht

    08/18/2020, 9:03 AM
    I'm struggeling with kotlin-main-kts that does not resolve transitative implementation and runtimeOnly dependencies. I would rather not set all my library dependencies to api. Should it be like that? Is there a more suited channel to ask?
    s
    • 2
    • 2
  • y

    Yuri

    08/18/2020, 9:09 AM
    In 1.4 there seems to be limitation for functional interfaces - suspend functions are not supported. Why? Is it final language design decision or temporal limitation of some kind?
    fun interface Plugin {
      suspend fun onFinish()
    }
    ‘suspend’ modifier is not allowed on a single abstract member
    ❓ 4
    d
    k
    r
    • 4
    • 8
  • p

    Paul Woitaschek

    08/18/2020, 10:27 AM
    Am I correct that using 1.4 the correct replacement of
    x.maxBy { ...}!!
    is
    x.maxByOrNull { ...}!!
    and that there is no replacement that throws if the result is null?
    b
    a
    s
    • 4
    • 15
  • a

    Alexander Schell

    08/18/2020, 11:24 AM
    Ouch! 😄 Ktolin 1.4.0:
    Caused by: java.lang.NoClassDefFoundError: kotlin/jvm/internal/KTypeBase
    Seems to be a problem with spring.
    ➕ 2
    m
    u
    • 3
    • 6
  • b

    Bruno_

    08/18/2020, 12:32 PM
    can you reference internal stuff in test sources in kotlin 1.4? 1.4.0-rc worked fine, after upgrading plugin and dependencies I keep getting
    Cannot access 'Foo': it is internal in 'some.package'
    gradle builds and runs it just fine tho
    a
    • 2
    • 2
  • l

    Luis Daivid

    08/18/2020, 2:10 PM
    I fork the Kotlin project. To build and run test code, I followed the official document exactly as it was.
    ./gradlew -Dhttp.socketTimeout=60000 -Dhttp.connectionTimeout=60000
    But it fails with this error.
    Exception in thread "main" java.lang.RuntimeException: Timeout of 120000 reached waiting for exclusive access to file: /Users/iLand/.gradle/wrapper/dists/gradle-6.6-bin/dflktxzwamd4bv66q00iv4ga9/gradle-6.6-bin.zip        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)        at org.gradle.wrapper.Install.createDist(Install.java:48)        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:107)        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:63)
    How can I run the test code of the project?
    a
    • 2
    • 1
  • r

    Ruckus

    08/18/2020, 2:16 PM
    Is there a shortcut to turning on the new IR for
    compileKotlin
    and
    compileTestKotlin
    at the same time? I just ran into an issue where I forgot to turn it on for tests (and it took far longer than it should have to realize my mistake and what the compiler was complaining about).
    u
    • 2
    • 2
  • s

    Sam Garfinkel

    08/18/2020, 3:26 PM
    Are there any pros/cons to using the new IR backend right now? Once the compiler API is stabilized obviously we’ll want to use the IR backend to support multiplatform plugins, but are there any benefits currently?
    r
    u
    • 3
    • 4
  • k

    kevin.cianfarini

    08/18/2020, 3:44 PM
    what's the rationale behind
    UInt.rotateLeft
    and
    UInt.rotateRight
    being normal functions and not
    infix
    ?
    🤔 1
    • 1
    • 1
  • c

    csturtevant

    08/18/2020, 4:48 PM
    Has anyone had trouble compiling a Spring + Kotlin project from Maven through
    mvn clean install
    , but had it compile and run from a Spring Boot configuration in Intellij? It works on 1.3.72, but not on 1.4.0. My 1.4.0 pom with just the version is linked: https://gist.github.com/csturtevant/e757a961344560d00ea08823a5cec3a1
    a
    • 2
    • 2
  • j

    Jose A.

    08/18/2020, 5:02 PM
    Hi everyone! Kotlin 1.4 plugin still not showing in Intellj 2020.2. It's weird because in Android Studio it upgraded right away...
    ➕ 2
    n
    • 2
    • 4
  • c

    Christopher Elías

    08/18/2020, 9:05 PM
    Hello, Im migrating an app from RxJava to Kotlin Flow. But, I can't find something that works like
    PublishSubject
    from RxJava. Does anybody have a sample of how to achive this?
    z
    • 2
    • 1
  • b

    basher

    08/18/2020, 9:42 PM
    Is Kotlin 1.4 (say a Kotlin 1.4 android app) supposed to be able to consume other Kotlin/JVM libraries still on 1.3.7x (i.e. backward compatible)?
    ➕ 1
    o
    l
    u
    • 4
    • 4
Powered by Linen
Title
b

basher

08/18/2020, 9:42 PM
Is Kotlin 1.4 (say a Kotlin 1.4 android app) supposed to be able to consume other Kotlin/JVM libraries still on 1.3.7x (i.e. backward compatible)?
➕ 1
o

oscarg798

08/18/2020, 11:19 PM
its working fine for me, I’m using also a library in 1.3.51 and it works
b

basher

08/18/2020, 11:22 PM
Huh okay. I might have found a bug then
l

louiscad

08/19/2020, 6:19 AM
Which library is causing you issues?
u

udalov

08/19/2020, 10:59 AM
Yes, Kotlin/JVM 1.4 is fully forwards- and backwards-compatible with 1.3. Please report an issue at https://kotl.in/issue if you found that it’s not the case!
View count: 2