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
compiler
  • b

    betterclever

    07/01/2021, 5:08 PM
    is there a way to profile the compiler compile task to see what exactly takes the most time?
    r
    s
    d
    • 4
    • 4
  • m

    martmists

    07/02/2021, 11:11 AM
    How would I get started with adding support for compiling kotlin to a different language?
    c
    • 2
    • 1
  • r

    rnett

    07/03/2021, 2:38 AM
    I'm using the bootstrap compiler to get ahead of breakage, but I'm seeing some issues that aren't ICEs but are normally things I would report to youtrack. For example, that the complier complains about
    RequiresOptIn
    annotations on parameters even when
    VALUE_PARAMETER
    is not one of the annotation's targets (it's on a constructor property). Should I report these now, or wait for EAP releases?
    d
    • 2
    • 1
  • b

    benkuly

    07/06/2021, 9:46 AM
    Hi 🙂 Is there an workaround for https://youtrack.jetbrains.com/issue/KT-42073 (I also asked here: https://discuss.kotlinlang.org/t/ir-compiler-throws-illegalstateexception-not-found-idx-for-public/22305) I feel quite lost, that nobody can help.
    r
    • 2
    • 3
  • m

    Maik

    07/08/2021, 7:22 AM
    Hi folks, I'm trying to build a compiler plugin to check if certain ID's are unique. The ID's are defined in the code as follows:
    @ErrorID
    val errorID: Long = 0x10A
    The ID's are found using the annotation and then their value is checked. But now I have encountered a problem. I want to do the check in a project with multiple modules and I am not clear how to manage or persist data in the plugin across modules. Are there any possible solutions for such use cases and if so, what do they look like? I would be very happy about some helpful comments!
    r
    l
    • 3
    • 2
  • m

    mcpiroman

    07/10/2021, 11:23 AM
    Kotlin repo build fails with
    > Task :libraries:tools:mutability-annotations-compat:compileJava FAILED
    error: Source option 6 is no longer supported. Use 7 or later.
    error: Target option 6 is no longer supported. Use 7 or later.
    on most recent master branch (de22a467a12714505a6f66f0a01bd7d7fc0ca9e2). Is it a know problem or something on my side?
    s
    u
    t
    • 4
    • 23
  • m

    Marcello Lelio Albano

    07/10/2021, 4:48 PM
    Does anyone know if there is a way to get the start line number from an IrFunction declaration? (working on a compiler plugin)
    s
    • 2
    • 2
  • s

    Slackbot

    07/12/2021, 12:13 AM
    This message was deleted.
    z
    c
    j
    • 4
    • 3
  • i

    Iaroslav Postovalov

    07/12/2021, 9:53 AM
    Hello. Is it possible to apply a Kotlin compiler plugin to a project with Gradle Included Builds feature?
    g
    • 2
    • 1
  • l

    Luca Piccinelli

    07/14/2021, 10:39 AM
    hello everyone! I'm trying to understand some difficult Kotlin to bytecode mechanics, in order to achieve better awareness on how to approach null checking. Can anyone help me with this stackoverflow question? https://stackoverflow.com/questions/68375988/why-do-kotlin-null-checks-when-decompiled-to-java-declares-some-unused-variable
    c
    • 2
    • 2
  • c

    Claus Rørbech

    07/16/2021, 10:15 AM
    I am trying to trigger generation of a companion object for classes implementing a specific interface in a compiler plugin by the following
    SyntheticResolveExtension
    :
    override fun getSyntheticCompanionObjectNameIfNeeded(descriptor: ClassDescriptor): Name? {
        return descriptor.getSuperInterfaces().firstOrNull { it.fqNameSafe == FqName("SOME_INTERFACE") }
            ?.let { DEFAULT_NAME_FOR_COMPANION_OBJECT }
    }
    It works for most cases but when having inner classes as generic type parameters, like:
    interface Generic<T>
    
    interface Outer : Generic<Outer.Inner> {
            class Inner
    }
    The check fails due to recursion in resolving the super interfaces (stack trace is in thread). Any suggestions on how to trigger generation of companion classes (or not) that would also work for this case by other means (APIs, phases, etc)?
    n
    d
    • 3
    • 6
  • v

    ventura

    07/20/2021, 4:07 PM
    Is there a diagram or document with the lexer/parser/etc... flow of Kotlin complier? I am trying to figure out how to write a compiler for other languages
    d
    r
    a
    • 4
    • 13
  • c

    Claudiu-Vlad Ursache

    07/29/2021, 12:47 PM
    Hi folks! I'm trying to find the correct PSI classes to use in order to get a
    KtNamedFunction
    from a
    KtCallExpression
    , or something similar. Is that possible at all, maybe with a Resolver or something? I followed the instructions in the documentation about
    getReferences()
    , but I get a null value for a very simple example like this one:
    fun add(x: Int, y: Int): Int {
        return x + y
    }
    
    fun main(args : Array<String>) {
        println(add(1 + 2, 3))   // <- How do I get from the PSI node of add to the PSI node of add's declaration
    }
    y
    • 2
    • 9
  • z

    Zac Sweers

    08/01/2021, 6:55 PM
    Are there any plans for an eventual stable API for kotlinx-metadata-jvm? We currently have to shade it due to the breaking APIs and it's making it difficult to maintain libraries that use it due to needing to update every 6 months to keep up with the kotlin update cycle (even if the library itself is stable). It would help a ton if we could un-shade it. This affects Moshi, Dagger, R8 (I think), and some others
    u
    • 2
    • 2
  • j

    jimn

    08/02/2021, 1:32 AM
    realistically which of these inlines cleaner?
    val foo by delegate::foo
    or
    inline val foo get()=delegate.foo
    I know which one shows up in the icicle graph like a bag of cinder blocks
    y
    e
    u
    • 4
    • 8
  • l

    louiscad

    08/04/2021, 2:07 PM
    Hello, did you ever think about making a compiler to check uniqueness of constants, or that they follow a suite (e.g.
    1..5
    ), or to generate unique values for constants? Use cases I have in mind: • Notifications ids, tags, and channel ids on Android • Loading steps to show how many there are and what is the current one • Ensured uniqueness of whatever id (number based, string based, or even primitive backed single property value class), across an app version, or through multiple updates of the same system (useful for communication between systems)
    w
    • 2
    • 1
  • l

    louiscad

    08/04/2021, 2:15 PM
    Another thing that would be nice is to be able to count how many invocations of a method are done within a scope. The use case is showing how many steps there are. Example:
    val stuff1: Stuff
    val stuff2: Something
    val nameOfWhatever: String
    withLoading("Doing something long") {
        stuff1 = step { getStuff(someInput) }
        stuff2 = step { getSomething(stuff1) }
        nameOfWhatever = step { fetchThing(someInput, stuff2) }
    }
    In the snippet above, I'd like
    withLoading
    to know how many calls to
    step
    there are in the lambda it's been passed, so it can show somewhere "Step 1/3" while
    getStuff(…)
    is executing. Currently, it's impossible to do, and having the desired result requires quite a bit of unsafe boilerplate, unsafe in that if I do a mistake like starting with step 3 instead of 1, the compiler won't spot it. Of course, there'd be concerns about having conditionally called
    step { … }
    calls, and possible nesting, plus one might want to provide some info to
    step
    to show on a UI what the next steps are (e.g. their title, some icon…)
    e
    • 2
    • 7
  • r

    Ryan Kay

    08/05/2021, 8:00 PM
    So far the biggest benefit of this approach is that it make the Debugging/Testing much easier as I could just step through and find out wherever the problems were. For drawbacks, I think it made the code more verbose, but I'm not typically too worried about that. There's also the potential to have the wrong Type returned in a Pair/Triple, but I'm building it using TDD to captures such problems. Anyways, I'm currently working on the Parser and I am planning to attempt a similar approach to generate the AST from my Tokens. My question is this: Is there some specific reason why global variables might be preferable for Lexing and Parsing? Might I be making some kind of huge mistake which will bite me down the road in later stages, or is it simply just going to result in a different and possibly more verbose code style? Thank you kindly for any info and perspectives. If you wanted to have a look at the full source so far, it's here.
    d
    • 2
    • 3
  • m

    mbonnin

    08/06/2021, 10:00 AM
    Is there a high level overview of what's in
    @Metadata
    ,
    *.kotlin_modules
    ,
    *.kotlin_metadata
    ,
    *.kotlin_builtins
    , what's safe to strip and what am I exposing myself to if I strip too much?
    ➕ 1
    z
    • 2
    • 11
  • m

    Marc Knaup

    08/09/2021, 9:48 PM
    I wonder if and how the new compiler front-end will affect performance of compiling DSLs? The more DSL I use in my project the more sluggish compiling and the IDE seem to become.
    ➕ 2
    c
    y
    f
    • 4
    • 5
  • m

    mbonnin

    08/13/2021, 11:32 AM
    Is there a way to compute calls to
    Foo::class.qualifiedName()
    at compile type and save them as constant strings to make sure they are not touched by proguard but still get intelliJ "FindUsages" if needed?
    e
    • 2
    • 2
  • y

    Youssef Shoaib [MOD]

    08/17/2021, 4:57 AM
    This could be useful as a first look into a (sort of) basic compiler plugin. Currently the code is lacking in comments, but that's because I cobbled it together in like 7 hours lol, and so if you notice any improvements or any mishaps that I've made, I'd love to hear your feedback!
    s
    • 2
    • 2
  • s

    Strum355

    08/18/2021, 5:10 PM
    I need to run static analysis on source jars containing Kotlin files with full name resolution. Im using K2JVMCompiler from kotlin-compiler-embeddable along with my analysis compiler plugin for this task. Classpath for an artifact is resolved using Coursier. Currently, Im attempting to analyze
    org.jetbrains.kotlin:kotlin-stdlib:1.5.21
    , but Im getting a lot of errors about
    /tmp/kotlin-stdlib/kotlin/util/Synchronized.kt:16:18: error: cannot access 'InlineOnly': it is internal in 'kotlin.internal'
    in the files that use these internal symbols.
    Having fixed the first error, Im still left with a host of
    /tmp/kotlin-stdlib/kotlin/util/NumbersJVM.kt:185:31: error: actual function 'countLeadingZeroBits' has no corresponding expected declaration
    and the same for other symbols. The args to K2JVMCompiler are as follows:
    -Xplugin=/home/noah/Sourcegraph/lsif-kotlin/semanticdb-kotlinc-1.0-SNAPSHOT.jar -P plugin:com.sourcegraph.lsif-kotlin:sourceroot=/tmp/kotlin-stdlib -P plugin:com.sourcegraph.lsif-kotlin:targetroot=/tmp/kotlin-stdlib/target -no-reflect -no-stdlib -Xno-check-actual -Xopt-in=kotlin.RequiresOptIn -Xopt-in=kotlin.ExperimentalUnsignedTypes -Xopt-in=kotlin.ExperimentalStdlibApi -Xopt-in=kotlin.contracts.ExperimentalContracts -Xopt-in=kotlin.ExperimentalMultiplatform -Xallow-kotlin-package -Xmulti-platform -nowarn -classpath /home/noah/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib/1.5.21/kotlin-stdlib-1.5.21.jar:/home/noah/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/annotations/13.0/annotations-13.0.jar:/home/noah/.cache/coursier/v1/https/repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-stdlib-common/1.5.21/kotlin-stdlib-common-1.5.21.jar
    Anyone any ideas?
    y
    r
    • 3
    • 5
  • t

    Thiago

    08/20/2021, 7:35 PM
    Posted in #serialization but this channel can help too maybe.
    e
    • 2
    • 3
  • c

    CLOVIS

    08/24/2021, 4:47 PM
    When the Kotlin documentation mentions the JVM being ‘open world’ and JS/Native being a ‘closed world compilation’, does that mean that it's not possible to declare an interface in Kotlin and then implement it in JS/C/...? Or did I completely misunderstand what it means?
    e
    t
    • 3
    • 15
  • z

    zak.taccardi

    08/24/2021, 7:40 PM
    In which context is
    --progressive
    mode useful? https://kotlinlang.org/docs/whatsnew13.html#progressive-mode For example,
    1.6
    will introduce a breaking change for
    when
    to make it always exhaustive. Would enabling progressive mode in
    1.5
    allow our code to be cross-compatible with both
    1.5
    and
    1.6
    in theory (assuming this change lands as a hidden option in the
    1.5
    compiler)?
    r
    d
    • 3
    • 2
  • j

    jessewilson

    08/24/2021, 8:48 PM
    I’m writing a Kotlin compiler plugin and I’d like to get a
    CompilerMessageSourceLocation
    from my
    IrElement
    , which happens to be an
    IrCallImpl
    so that I can call
    MessageCollector.report
    with a useful source location. Is there an API somewhere to extract a source location from an element?
    z
    • 2
    • 6
  • c

    CLOVIS

    08/25/2021, 1:49 PM
    Hi! I'm getting a
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during IR lowering
    error after migrating to 1.5.30. Where's the correct place to report it?
    m
    d
    • 3
    • 3
  • z

    Zac Sweers

    08/25/2021, 2:51 PM
    In 1.5.30 - do I see correctly that there is no option for 
    Xnullability-annotations
     to set everything to strict? Having to maintain a list of all the packages seems cumbersome. Would it be worth filing a FR if so?
    • 1
    • 1
  • s

    suresh

    08/26/2021, 6:28 AM
    Getting NPE on kapt task 😬 (using Kotlin
    1.5.30
    , Lang Level
    1.6
    & Jdk 17). Has anybody seen this error?
    > Task :kaptGenerateStubsKotlin
    ....
    
    w: Language version 1.6 is experimental, there are no backwards compatibility guarantees for new language and library features
    w: ATTENTION!
    This build uses unsafe internal compiler arguments:
    
    -XXLanguage:+JvmRecordSupport
    
    This mode is not recommended for production use,
    as no stability/compatibility guarantees are given on
    compiler or generated code. Use it at your own risk!
    
    w: Language version 1.6 is experimental, there are no backwards compatibility guarantees for new language and library features
    Compilation with Kotlin compile daemon was not successful
    java.lang.NullPointerException
            at org.jetbrains.kotlin.incremental.IncrementalJvmCache.addToClassStorage(IncrementalJvmCache.kt:494)
            at org.jetbrains.kotlin.incremental.IncrementalJvmCache.saveFileToCache(IncrementalJvmCache.kt:171)
            at org.jetbrains.kotlin.incremental.BuildUtilKt.updateIncrementalCache(buildUtil.kt:110)
            at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.updateCaches(IncrementalJvmCompilerRunner.kt:326)
            at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.updateCaches(IncrementalJvmCompilerRunner.kt:112)
    d
    t
    • 3
    • 4
Powered by Linen
Title
s

suresh

08/26/2021, 6:28 AM
Getting NPE on kapt task 😬 (using Kotlin
1.5.30
, Lang Level
1.6
& Jdk 17). Has anybody seen this error?
> Task :kaptGenerateStubsKotlin
....

w: Language version 1.6 is experimental, there are no backwards compatibility guarantees for new language and library features
w: ATTENTION!
This build uses unsafe internal compiler arguments:

-XXLanguage:+JvmRecordSupport

This mode is not recommended for production use,
as no stability/compatibility guarantees are given on
compiler or generated code. Use it at your own risk!

w: Language version 1.6 is experimental, there are no backwards compatibility guarantees for new language and library features
Compilation with Kotlin compile daemon was not successful
java.lang.NullPointerException
        at org.jetbrains.kotlin.incremental.IncrementalJvmCache.addToClassStorage(IncrementalJvmCache.kt:494)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCache.saveFileToCache(IncrementalJvmCache.kt:171)
        at org.jetbrains.kotlin.incremental.BuildUtilKt.updateIncrementalCache(buildUtil.kt:110)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.updateCaches(IncrementalJvmCompilerRunner.kt:326)
        at org.jetbrains.kotlin.incremental.IncrementalJvmCompilerRunner.updateCaches(IncrementalJvmCompilerRunner.kt:112)
d

dmitriy.novozhilov

08/26/2021, 8:21 AM
Please file an issue https://kotl.in/issue
t

Tomasz Krakowiak

08/26/2021, 2:23 PM
You may also want to check out - https://youtrack.jetbrains.com/issue/KT-45545
s

suresh

08/26/2021, 2:54 PM
@Tomasz Krakowiak thanks..i do have all the workaround mentioned (add-opens for strong encapsulation) and is working on lang version 1.5. Issue happens only with 1.6.
@dmitriy.novozhilov https://youtrack.jetbrains.com/issue/KT-48421
View count: 1