https://kotlinlang.org logo
Docs
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
  • u

    uli

    09/04/2019, 1:28 PM
    I am puzzeled by the fact that the following snippet compiles:
    val x : (()->Unit)? = null
    
    
    fun main() {
        if (x != null) {
            x.invoke()
        }
    }
    while with this one the compiler complains about the reference having a nullable type:
    val x : (()->Unit)? = null
    
    
    fun main() {
        if (x != null) {
            x()
        }
    }
    Compiler and Android Studio even agree on complaining about the second snippet. Am I missing something?
    j
    w
    3 replies · 3 participants
  • s

    Shannon Yang

    09/10/2019, 7:56 PM
    Hi! I've been poking around
    IrGenerationExtension
    , and am trying to add a function to annotated classes that just prints "Hello World". I got stuck figuring out how to find the
    println
    descriptor or symbol to build the function call through
    IrCallImpl
    . Does anyone know where I could find an example, or another way I could go about this? Thanks!
    r
    d
    +1
    13 replies · 4 participants
  • s

    Stumpos

    09/11/2019, 10:22 PM
    is anyone familiar with the :generators:test-generator module in the kotlin compiler repo? I'm trying to generate tests and I'm assuming 'testClasses' task is the task responsible for generating the tests.
    1 reply · 1 participant
  • s

    Stumpos

    09/12/2019, 7:21 PM
    What are the compile times people are experiencing? I'm new to the Kotlin compiler development and it takes about 40 seconds to compile (context: debugging plugin tests). Is this normal?
    r
    1 reply · 2 participants
  • f

    Foso

    09/13/2019, 3:51 PM
    Hi, i want to detect annotated expressions. Does someone know which class i could use for that?
    r
    s
    4 replies · 3 participants
  • s

    spierce7

    09/16/2019, 4:06 PM
    How stable is the IR api? Is it safe to start using to develop a compiler plugin?
    f
    i
    7 replies · 3 participants
  • j

    josephivie

    09/18/2019, 12:40 AM
    Where can I find the Kotlin Native compiler artifacts on Maven? Or does that not exist? I'm working on an alternative build tool and have had little luck going through the repository to find any public embedded compiler like there is for JS and JVM. I could always run them through the command line, but I'd prefer to keep the fully-typed interface from the source if there's one available.
    g
    2 replies · 2 participants
  • r

    raulraja

    09/21/2019, 4:21 PM
    As I work on testing the Arrow codebase with Arrow Meta and IR enabled on I’m finding many unsupported and missing cases in IR translation even in the JVM target. Is there a public list or way to track what is missing?. We could help contributing the missing pieces to the compiler if that helps us in any way getting there faster.
    d
    b
    7 replies · 3 participants
  • s

    Stumpos

    09/25/2019, 4:49 PM
    Is anyone familiar with the automated test setup in the compiler? I added some tests to verify IR pass code transformation is correct, and although my test passes it fails because its being included in another test suite where it cannot find my test data. I want to exclude my test from this suite, but I'm having a hard time locating where this inclusion is specified. The stack trace is unhelpful and the error message searches yields no result. The problem test suite is android-tests
    1 reply · 1 participant
  • z

    Zac Sweers

    09/26/2019, 9:15 AM
    I’ve got an issue filed regarding generating
    .class
    files directly via Kapt, but I’m wondering actually if this is a bug in the compiler itself by virtue of not putting
    .class
    source roots on the compile classpath (so other code can link against it). I’ve been looking at how gradle handles this, and while it supports generating class files directly via annotation processing, its annotation processing machinery doesn’t actually appear to do anything special to ensure the class file is on the compile classpath. It just hands it over to the compiler. Issue for ref: https://youtrack.jetbrains.com/issue/KT-33847 I’m wondering if this should be reassigned as a kotlinc bug basically.
    y
    3 replies · 2 participants
  • t

    Timmy

    09/27/2019, 2:41 PM
    I am trying to find the cause of this bug in Moshi: https://github.com/square/moshi/issues/615 (more out of interest than need). The issue is that Moshi and Retrofit have different notions of what the generic type actually is. The underlying cause is that
    Foo<Nothing?>
    (and
    Foo<Nothing>
    ) compile to a raw type. While that is fine for the runtime it means losing generic information where it would be normally available (such as in method signatures). I have found this (https://github.com/JetBrains/kotlin/commit/9acf3e40de2d22318f9d3eda15e5da47117edbc4#diff-efccdee550f101125771902fc631175a) commit that implemented the Nothing -> raw type conversion. I could not find an explanation. Does someone know the reason behind this decision? How could I recover the Nothing generic argument? Is this the only case that compiles to a raw type?
    d
    t
    +1
    4 replies · 4 participants
  • a

    Akram

    10/01/2019, 7:57 PM
    is there any nice blog posts on how to create a kotlin compiler plugin ?
    f
    t
    +2
    7 replies · 5 participants
  • t

    thanh

    10/02/2019, 6:44 AM
    Can we write a custom syntax for Kotlin with a compiler plugin? Like union type:
    type newType = typeA | typeB
    ?
    🇳🇴 2
    r
    1 reply · 2 participants
  • t

    turansky

    10/02/2019, 6:54 AM
    Is there possibility to enrich JS
    prototype
    via compiler plugin?
    // Kotlin
    class A: B
    
    // compiled JS
    A.prototype = Object.create(B)
    
    // compiled JS + enrich
    A.prototype = Object.create(enrichMethod(B))
    Can it be realized using
    JsSyntheticTranslateExtension
    ?
    b
    6 replies · 2 participants
  • j

    jdemeulenaere

    10/03/2019, 12:10 PM
    Is there some util functions I can use to know the expected type at some position in a KtFile ? for instance let's say I have a method
    doSomething(s: String)
    we know that when calling this function the expected value inside the
    ()
    should be a string. Is there anything in
    kotlin-compiler
    that already does all of this kind of logic and returns a
    KotlinType
    ?
    i
    r
    +1
    14 replies · 4 participants
  • r

    raulraja

    10/04/2019, 6:45 PM
    I’m experience an odd behavior when repackaging compiler plugins with the gradle shadow plugin. If I depend in the shadowed version of the compiler plugin once the compiler loads my plugin I always get:
    e: java.lang.IllegalStateException: The provided plugin arrow.meta.MetaPlugin is not compatible with this version of compiler
    My current config for the shadow plugin looks like:
    shadowJar {
        configurations = [project.configurations.compile]
        relocate 'org.jetbrains.kotlin.com.intellij', 'com.intellij'
        dependencies {
            exclude(dependency {
                it.moduleGroup.startsWith('org.jetbrains') || it.moduleGroup.startsWith('org.intellij')
            })
        }
        //relocate 'org.jetbrains.kotlin.load', 'kotlin.reflect.jvm.internal.impl.load'
    }
    Same behavior regardless if I include the embedded Kotlin deps or not. Whenever I shadow a compiler plugin I get that error. does anyone know if there is a special setting or something I am missing?. The only difference between the jars I’ve noticed is that due to the package relocation the shadowed version may have different size .class files. Any help is much appreciated. Thanks.
    h
    k
    +1
    21 replies · 4 participants
  • v

    ventura

    10/06/2019, 11:57 AM
    Dummy question about Kotlin to JVM compiler: 1. Was it implemented from scratch in Java? 2. Was it implemented using some standard Java lexer/parser framework? 3. Was it implemented using LLVM, compiled to LLVM IR and later compiled to JVM bytecode?
    d
    t
    +1
    8 replies · 4 participants
  • t

    tschuchort

    10/06/2019, 5:07 PM
    The Kotlin compilation process works in several stages: - First the compiler is called with the kapt plugin which generates Java stub files from the Kotlin files and then calls apt with that. AFAIK the kapt plugin "shortwires" the rest of the compilation, so that no actual compilation of Kotlin sources takes place in this stage - Then the Kotlin compiler is called regularly to compile the Kotlin sources - Finally the Java compiler is called to compile all Java sources, with the compiled Kotlin class-files from the previous step on the classpath. My question is: Do third-party compiler plugins get passed to both the first 2 stages or just in the 2nd stage? Does the kapt plugin prevent the execution of further compiler plugins as well, like it shortwires the regular compilation?
    r
    i
    +1
    41 replies · 4 participants
  • a

    Akram

    10/08/2019, 7:26 PM
    I'm just starting writing compiler plugins and just want to ask if there is a way to log in the extensions , or debug the compiler (that would be perfect )
    i
    f
    13 replies · 3 participants
  • a

    Akram

    10/09/2019, 1:54 PM
    hello ! just want to know if given a functionDescriptor can we know if this is a topLevel function or a Function inside a class ?
    k
    2 replies · 2 participants
  • a

    Akram

    10/09/2019, 5:56 PM
    Hey , i'm writing a kotlin compiler plugin that will generate code that use some android classes how can i generate code that use the android classes like View.java ?
    f
    g
    +1
    11 replies · 4 participants
  • a

    aurimas

    10/11/2019, 4:00 PM
    After updating to the latest version of UAST, it seems that it hides any functions that take/return
    reified
    types. For example:
    package test.pkg
    inline fun <reified T> Context.systemService1() = getSystemService(T::class.java)
    inline fun Context.systemService2() = getSystemService(String::class.java)
    For this
    PsiClassItem
    call to
    methods
    only returns 1 method (the one without
    reified
    ). Removing
    reified
    brings it back, going back to older version of UAST also brings it back. I was wondering if this sounds familiar to anyone?
    3 replies · 1 participant
  • h

    Henry

    10/14/2019, 1:18 PM
    Hi everyone, I'm new to the kotlin compiler (but not new to kotlin or compilers), are there any resources you would recommend other than the source for getting started with compiler/compiler plugin development? Thanks!
    i
    12 replies · 2 participants
  • d

    Daniel Rampelt

    10/14/2019, 3:46 PM
    Hey, has anyone had any experience with a compiler plugin that works for both JVM and native? I've got a JVM plugin working but having some trouble getting plugins to work for native. I've been compiling against
    kotlin-compiler-embeddable
    (which has been working great for JVM) but it seems to have a bunch of dependencies remapped under
    org.jetbrains.kotlin
    . The problem is
    konanc
    , even when run from gradle just like I'm doing for JVM, doesn't seem to have those packages remapped so my plugin doesn't load since it's referencing the wrong classes. Is it possible to write a plugin that works for both JVM/native at the moment?
    f
    s
    3 replies · 3 participants
  • a

    Akram

    10/17/2019, 3:21 PM
    Hi everyone , i'm making a compiler plugin so i got 3 module : the gradle plugin module , the kotlin compiler module and a runtime module that hold my annotation , so i want the module to be used only in android applications so to do so the runtime module must be only accessed from android modules how can i achieve that . after inspecting the android extensions plugins i've noticed that they hide the runtime module inside the 'kotlin-android' plugin is there a way to do so ?
    r
    2 replies · 2 participants
  • i

    Imran/Malic

    10/18/2019, 11:19 AM
    Is someone familiar with ASM Transformations?
    d
    14 replies · 2 participants
  • i

    Imran/Malic

    10/21/2019, 10:03 AM
    What does Fir stand for in Kotlin compiler?
    k
    r
    +3
    22 replies · 6 participants
  • l

    louiscad

    10/22/2019, 9:29 AM
    I'm seeing override by an inline function is only a warning that can be suppressed. What happens under the hood when I do it? Tries to resolve to inline when the type is the impl of the interface?
    i
    k
    7 replies · 3 participants
  • j

    jdemeulenaere

    10/23/2019, 9:10 AM
    Hi all! I am writing a Kotlin plugin code, and at some point I would like to get all candidates descriptors of a (incomplete) function call. The code below works for calls that have only one possible candidate, but not for calls with multiple candidates/overloads :
    val context: BindingContext = ...
    val callExpression: KtCallExpression = ...
    val call = callExpression.getCall(context)
    val resolvedDescriptor = call?.getResolvedCall(context)?.candidateDescriptor
    
    if (resolvedDescriptor == null) {
      // TODO: Find a list of candidate descriptors.
    }
    For example, the following code:
    fun hello(s: String) { ... }
    fun helloWithOverload(s: String) { ... }
    fun helloWithOverload(i: Int) { ... }
    
    fun main() {
      hello("foo") // will be correctly resolved
      hello() // will be correctly resolved as there is only one possible call
      helloWithOverload("foo") // will be correctly resolved as the call is complete
      helloWithOverload() // won't be resolved as the call is incomplete and there are multiple candidates
    }
    My question: what methods can I use to find those candidates ? Thanks a lot 🙂
    r
    2 replies · 2 participants
  • a

    Andrey Tarasevich

    10/24/2019, 9:50 AM
    Hello everyone. We are using Hazelcast in our Kotlin project and Hazelcast asks for Java internal API, i.e. it asks to add these flags to javac
    --add-modules <http://java.se|java.se> --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens jdk.management/com.ibm.lang.management.internal=ALL-UNNAMED
    Does anyone know, how to do something similar for Kotlin compiler? Is it possible at all? Maybe I'm missing something
    g
    3 replies · 2 participants
Powered by Linen
Title
a

Andrey Tarasevich

10/24/2019, 9:50 AM
Hello everyone. We are using Hazelcast in our Kotlin project and Hazelcast asks for Java internal API, i.e. it asks to add these flags to javac
--add-modules <http://java.se|java.se> --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED --add-opens jdk.management/com.ibm.lang.management.internal=ALL-UNNAMED
Does anyone know, how to do something similar for Kotlin compiler? Is it possible at all? Maybe I'm missing something
g

gildor

10/24/2019, 9:52 AM
Why do you need this for Kotlin compiler?
a

Andrey Tarasevich

10/24/2019, 10:22 AM
The reason is - i don't actually know, if I need it for Kotlin compiler. I just can't find a way how to open these modules for Hazelcast during project compilation
nvm, i found the issue. It's between the keyboard and the chair 😉
View count: 25