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
  • p

    PHondogo

    07/27/2020, 9:22 PM
    I've created compiler plugin that in IR phase add secondary constructor for those two classes. Part of code related to constructor creation: val c = klass.addConstructor { visibility = Visibilities.PUBLIC } c.addValueParameter { this.index = 0 this.name = Name.identifier("stub") this.type = pluginContext.irBuiltIns.unitType } c.body = IrBlockBodyImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, listOf( IrDelegatingConstructorCallImpl( UNDEFINED_OFFSET, UNDEFINED_OFFSET, superConstructor.returnType, superConstructor.symbol, superConstructor.typeParameters.size, if (superClassIsAny) 0 else 1 ).also { constructorCall -> val anyType = pluginContext.irBuiltIns.anyType for (param in superConstructor.typeParameters.withIndex()) { constructorCall.putTypeArgument(param.index, anyType) } if (!superClassIsAny) { constructorCall.putValueArgument(0, pluginContext.unitValue) } } ) ) When compiling it got exception stack trace (only for JS, JVM compiles successfully): e: java.lang.IllegalStateException: Not found Idx for public my.package/A|null[0] at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.resolveSignatureIndex(KotlinIrLinker.kt:289) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.loadTopLevelDeclarationProto(KotlinIrLinker.kt:296) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.deserializeDeclaration(KotlinIrLinker.kt:268) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile$FileDeserializationState.processPendingDeclarations(KotlinIrLinker.kt:256) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$IrDeserializerForFile.deserializeAllFileReachableTopLevel(KotlinIrLinker.kt:431) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$BasicIrModuleDeserializer$ModuleDeserializationState.processPendingDeclarations(KotlinIrLinker.kt:99) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker$BasicIrModuleDeserializer.deserializeReachableDeclarations(KotlinIrLinker.kt:208) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.deserializeAllReachableTopLevels(KotlinIrLinker.kt:501) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.findDeserializedDeclarationForSymbol(KotlinIrLinker.kt:520) at org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker.getDeclaration(KotlinIrLinker.kt:554) at org.jetbrains.kotlin.ir.util.ExternalDependenciesGeneratorKt.getDeclaration(ExternalDependenciesGenerator.kt:66) at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:56) at org.jetbrains.kotlin.ir.backend.js.KlibKt.loadIr(klib.kt:282) at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile(compiler.kt:53) at org.jetbrains.kotlin.ir.backend.js.CompilerKt.compile$default(compiler.kt:48) at org.jetbrains.kotlin.cli.js.K2JsIrCompiler.doExecute(K2JsIrCompiler.kt:221) at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:181) at org.jetbrains.kotlin.cli.js.K2JSCompiler.doExecute(K2JSCompiler.java:74) at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:86) 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:1549) at jdk.internal.reflect.GeneratedMethodAccessor28.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:567) 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(AccessController.java:691) 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(AccessController.java:391) 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:830) If remove type parameter, or move B class to first module then compilation succed.
    ✔️ 1
    r
    • 2
    • 13
  • r

    rnett

    07/29/2020, 8:38 AM
    I've been drooling over the new Fir plugin api and had a few questions: 1. Will it make it into 1.4? In particular
    FirDeclarationGenerationExtension
    and the others that didn't make it into the RC 2. Is defining method/class bodies allowed in those methods? I.e. can I define a method body in
    FirDeclarationGenerationExtension.generateMembers
    ? The AllOpen examples don't, and
    generateMembersForGeneratedClass
    is a thing instead of just adding members to the class. 3. Will using the Fir extensions replace
    SyntheticResolveExtension
    with regards to having added definitions show up in the IDE (it sure looks like it)?
    r
    d
    • 3
    • 10
  • p

    Petter Måhlén

    07/30/2020, 7:26 AM
    hi, i've spent many days over the last few weeks or so trying to figure out https://github.com/bazelbuild/rules_kotlin/issues/342 - an issue where there is a KotlinReflectionNotSupportedError when trying to use Bazel to build a Kotlin project with an annotation processor that requires reflection. The maintainers of the Bazel rules_kotlin project seem unable to provide any insight, but I figured that maybe someone here could. In particular, I wonder if anyone has any insights into whether it might be a) a version conflict between the version of kotlin-stdlib and kotlin-reflect that eventually get used, or b) a timing issue, perhaps due to the use of
    ClassPreloadingUtils.preloadClasses
    in https://github.com/bazelbuild/rules_kotlin/blob/master/src/main/kotlin/io/bazel/kotlin/builder/toolchain/KotlinToolchain.kt#L70, that means that the
    Reflection
    class gets initialised at a point in time when reflection isn't added? c) or something completely different. There's a lot of ground to cover in all the Kotlin compilation ecosystem as well as the Bazel stuff, and I'm new to both. Help very much appreciated, if possible!
    r
    h
    • 3
    • 9
  • s

    sean

    07/31/2020, 11:22 PM
    I have a project that's ~360k lines of Kotlin code (~20k written by humans ~340k generated) and locally it takes about 8 minutes to run (the compileKotlin step, I'm using Gradle, laptop is a macbook w/ 3.1 GHz Quad-Core Intel Core i7 and I know this result is not particularly scientific) I was wondering — does anyone know whether this is around the expected runtime given this much kotlin? Are there particularly expensive types of things to compile? Any way I could profile it? Compile times are getting painful for folks so anything I can do to relieve some of this will be helpful if there are suggestions.
    d
    r
    • 3
    • 12
  • m

    Manuel Wrage

    08/02/2020, 11:42 AM
    Hey, Is there a way to transform an IrCall of an inline external library function after the function body has been inlined? I need some information from the call side for applying those informations. Are there any alternative way to accomplish this?
    🇳🇴 1
    s
    • 2
    • 8
  • i

    iFrankWang

    08/04/2020, 2:24 AM
    Hi, I've been trying to get Mapstruct plugin work for kotlin, so far I'm stucked to getting the return type of the function. How do i get 
    KtNamedFunction
     's return type in form like "`xxx.xxx.TestClass`"? I've only managed to get the short class name as "`TestClass`" with code like this:
    ktNamedFunction.getTypeReference().getText()
    And here's Mapstruct plugin in Github: https://github.com/mapstruct/mapstruct-idea
    s
    • 2
    • 10
  • b

    bod

    08/04/2020, 3:07 PM
    Hello, World! What can you do when you get this kind of errors:
    > Task :app:compileDebugKotlin
    e: org.jetbrains.kotlin.codegen.CompilationException: Back-end (JVM) Internal error: wrong bytecode generated
    ?
    w
    • 2
    • 28
  • j

    jereksel

    08/10/2020, 6:06 PM
    Hi, I'm rewriting my plugin written in Kotlin 1.3 with Java bytecode generation to Kotlin 1.4 with IR generation. Unfortunately my
    SyntheticResolveExtension
    stopped working and it throws following error:
    e: java.lang.IllegalArgumentException: Unbound type parameters are forbidden: [Unbound private symbol org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl@45e9c41b]
    	at org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator.generateUnboundSymbolsAsDependencies(ExternalDependenciesGenerator.kt:36)
    	at org.jetbrains.kotlin.psi2ir.generators.ModuleGenerator.generateUnboundSymbolsAsDependencies(ModuleGenerator.kt:62)
    I'm creating type parameters with
    TypeParameterDescriptorImpl.createWithDefaultBound
    , so I wasn't expecting any issues with bounds - especially, because it was working before. Is it known issue? I can create sample reproduction project if it's required.
    s
    r
    • 3
    • 5
  • s

    Steve

    08/10/2020, 10:52 PM
    I'm getting a "Cannot access class. Check your module class path for missing or conflicting dependencies' when trying to run an android app on device and when trying to run the tests. When just running, a simple clean and rebuild is enough to make it go away, but that doesn't work for running tests. Where is that class path that it's talking about?
    w
    j
    p
    • 4
    • 9
  • g

    gpeal

    08/17/2020, 6:58 PM
    Hi there, I found a bug in the new 1.4 type inference that is going to cause huge headaches for any apps that use MvRx (Airbnb, Dropbox, Netflix, Tonal, Turo, among many others) https://youtrack.jetbrains.com/issue/KT-41135 Have any of you encountered this?
    m
    • 2
    • 10
  • j

    jereksel

    08/18/2020, 10:06 AM
    Hi, one of the things I find difficult while building compiler plugins is that source jar for kotlin-compiler-embeddable is empty. I'm trying to build Gradle plugin for generating this jar from git sources, but with mixed results (https://gradle-community.slack.com/archives/CA745PZHN/p1597353800010600) In any case, is uploading source jar with files on roadmap?
    👍 2
    ➕ 1
    r
    s
    m
    • 4
    • 5
  • j

    Jacob Applin

    08/18/2020, 6:46 PM
    I just benchmarked the new IR compiler on my project and I'm seeing it's 20 percent slower for clean builds, is this a normal result right now?
    u
    • 2
    • 1
  • f

    FalseHonesty

    08/18/2020, 9:34 PM
    Hi, I'm looking into making an IR compiler plugin with 1.4.0, but I seem to be having an issue with my Transformer. For reference, my code is here: https://gist.github.com/FalseHonesty/c76cef82585b0f5f0052a01e54d520b3. The
    lower
    function in my Transformer class seems to be called correctly, but my two visitors never seem to be called. I attempted to debug what happens in the
    lower
    function, but execution gets passed to a class called
    IRDeclarationBase
    when visiting the
    main
    function, which is a class I can't find the source for. Nothing seems to be called after that. Does anyone have any ideas as to what I'm doing wrong?
    s
    • 2
    • 3
  • f

    FalseHonesty

    08/19/2020, 4:16 AM
    Additionally, is there any way to know if
    TypeResolutionInterceptorExtension
    will become non-internal anytime soon? I'd like to be able to use it in my compiler plugin 🙂
    🇳🇴 1
    r
    • 2
    • 33
  • h

    huehnerlady

    08/19/2020, 8:05 AM
    Hi, not sure if I am right herem but as it has something to do with compiling I was thinking maybe here? It is about the smartCast. I appreciate that not all possibilities are covered, but I thought this scenario would work. I seem to be wrong? Or I did not add something which enables smartcast?
    I have the following sample function:
    fun test(){
      val testString: String?  = null
      testString ?: throw IllegalArgumentException("null")
      print(testString.length)
    }
    I now want to extract the exception throwing to make clear why I do this:
    fun test2(){
      val testString: String?  = null
      testString ?: handleUnexpectedNull()
      print(testString.length)
    }
    
    private fun handleUnexpectedNull() {
      throw IllegalArgumentException("null")
    }
    But here I get a compile error (see screenshot). Why is this happening and can I extract the exception in a way that still supports smartcast? I am using the jvm compiling and kotlin 1.3.72
    ☑️ 2
    g
    • 2
    • 5
  • i

    Imran/Malic

    08/21/2020, 2:45 PM
    Hi all, Prior to 1.3.71 there was a member
    descriptor
    , which would return the resolved call at the call-site. It has been removed ever since in this PR and was wondering if someone knows a way to go from IrCall -> CallableMemberDescriptor in the IrPhase. In my use case I can’t access the psiElement at call-site only the one in the symbol from the original declaration, which is not resolved - regarding type arguments etc. that is:
    { expression: IrCall -> expression.symbol.owner.descriptor.original.findPsi()
    } // returns the PsiElement
    but
    { expression: IrCall-> BindingTraceContext.createTraceableBindingTrace().bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, expression.symbol.owner.descriptor.original.findPsi()) } // returns always null
    prior to 1.3.71 one would only need to do:
    { expression: IrCall -> expression.descriptor } // returns CallableMemberDescriptor, which is fully resolved
    Any help is very welcome 😄
    i
    u
    • 3
    • 7
  • o

    Omar Mainegra

    08/23/2020, 4:31 PM
    Hi, in 1.4.0, my code takes a long time to compile, sometimes it hasn't finished after hours. I suspect is the new type inference algorithm because Idea freezes when I open the file. I narrowed the issue to some functions with with up to 24 type parameters (24 functions from 1 to 24). Is there a way to disabled the new algorithm?
    • 1
    • 2
  • m

    Marc Knaup

    08/24/2020, 1:33 PM
    It would be awesome if
    when
    expressions over a String with plenty of constant cases could be optimized somehow, e.g. by using tableswitches for 1st & 2nd character (esp. if latin) or by using hashes. Right now such cases will just repeatedly call
    equals
    which can be much slower. For now I’m using a
    HashMap
    with
    String
    as key and a lambda as value but the lambdas will create a crazy amount of anonymous classes. I’ve also tried a
    HashMap
    to
    Int
    and then use the
    Int
    for the
    when
    expression but for whatever reason that was slower 😮 Prbl. because of boxing.
    u
    • 2
    • 2
  • h

    huehnerlady

    08/25/2020, 11:14 AM
    Hi, I have a problem with the usage of the `Lists.filterNotNull() extension. The function is described as follows:
    public fun <T : Any> Iterable<T?>.filterNotNull(): List<T> {
        return filterNotNullTo(ArrayList<T>())
    }
    So I expect I can use it with a non-nullable list with nullable items, and I get a non-nullable list with just non-nullable items back. But when I use this method like so:
    fun List<String?>?.extract(): List<String> =
        this?.filterNotNull().map {
          "foo"
        }.toList()
    I get a compiler error as shown in my screenshot. Why is this the case? I would have expected that the output is a non-nullable list, at least that is what I read out of the signature? I am using kotlin 1.3.72
    ☑️ 1
    b
    d
    • 3
    • 6
  • f

    FalseHonesty

    08/25/2020, 7:07 PM
    Hello, I've written a compiler plugin for the new 1.4.0 IR compiler backend, and I am now using it in a project of mine. I want to see the bytecode output, and to do so I am using the IntelliJ "Kotlin Bytecode Viewer" built-in tool. In that tool, there is a checkbox for using IR, so I enabled it, but it caused this error when trying to display the bytecode:
    java.lang.IllegalStateException: No module deserializer found for <library Gradle: net.minecraft:minecraftSrc:1.12.2> is a module[ModuleDescriptorImpl@5c013a11]
    . I'm not sure what this means?
    u
    • 2
    • 4
  • a

    Adam

    08/28/2020, 3:15 AM
    message has been deleted
    u
    • 2
    • 2
  • c

    caelum19

    08/28/2020, 3:35 PM
    Hey guys, in theory how hard would it be to do real-time interpretation of Kotlin code? Is there anyone doing anything like this now? Without safety and performance optimisations of course
    h
    e
    • 3
    • 7
  • t

    tmphey

    08/29/2020, 10:25 AM
    Hello guys 👋 I’m starting to dig into compiler plugins and wonder if there is some documentation about the compiler plugin api? I tried a quick search in google but haven’t found anything similar to docs. Does it exist? Thanks!
    h
    f
    +2
    • 5
    • 7
  • m

    Marc Knaup

    09/01/2020, 12:54 PM
    Do compiler plugins have to create code/implementations “in-memory” (like Kotlin Serialization does) or can they also generate
    .kt
    files as you would with annotation processing?
    t
    g
    • 3
    • 36
  • i

    Imran/Malic

    09/03/2020, 12:56 PM
    Hi all, when the symbolTable is being deprecated, what should one use instead https://github.com/JetBrains/kotlin/blob/257c4c560451c15d20edebc3926f6eba7d0f9f35/compiler/ir/backend.common/src/org/jetbrains/kotlin/backend/common/extensions/IrPluginContext.kt#L31? 😄 Any help is welcome
    s
    • 2
    • 3
  • j

    James Hamilton

    09/03/2020, 3:29 PM
    Hi all 🙂 will there be a new
    kotlinx-metadata-jvm
    package published to mvn? The metadata generated by kotlinc 1.4 does not work with the metadata-jvm 0.1.0 version
    u
    • 2
    • 11
  • g

    genovich

    09/06/2020, 11:19 AM
    Hi! I want to generate default
    toString()
    implementation for
    object
    classes. How I can do that? Should I use kapt or is there some way to do it via compiler plugin?
    s
    • 2
    • 1
  • n

    Nabil

    09/07/2020, 6:06 PM
    Hi, is there a reason why
    isIntOrNullableInt
    is not available in
    KotlinBuiltIns
    ? (similar for example to
    isLongOrNullableLong
    ). When using a property
    var age:Int?
    isInt
    returns
    false
    (which is correct)
    isNullablePrimitiveType
    returns
    true
    (which is correct), but there's no mechanism to detect a return type is
    Int
    or
    Int?
    d
    r
    • 3
    • 12
  • s

    Sebastian Kaspari

    09/08/2020, 9:34 AM
    Random grammar question: Why are there two start symbols
    kotlinFile
    and
    script
    ? `kotlinFile`'s
    topLevelObject
    seems to only contain declarations. What is this used for? 🙂 (https://kotlinlang.org/docs/reference/grammar.html#syntax-grammar)
    m
    • 2
    • 2
  • s

    Strum355

    09/13/2020, 9:47 PM
    Curious to know how, in a java+kotlin(+other jvm lang) source project, how are the types resolved from the non kotlin source code?
    r
    e
    u
    • 4
    • 10
Powered by Linen
Title
s

Strum355

09/13/2020, 9:47 PM
Curious to know how, in a java+kotlin(+other jvm lang) source project, how are the types resolved from the non kotlin source code?
r

raulraja

09/13/2020, 10:57 PM
In the current compiler frontend 3rd party symbols incoming from jars and other places in the class path result into descriptors that contains the type info. If those binaries were generated by the Kotlin compiler they include the Kotlin metadata attached to the binaries in annotations that the compiler can then read when compiling a local project. Still jars created with Scala, Clojure and others are seen by the compiler as Javac would. Potentially they create and persist their own metadata too.
s

Strum355

09/13/2020, 11:04 PM
So does that mean the compiler expects the projects' Java sources to be compiled before the Kotlin sources are?
e

ephemient

09/14/2020, 5:18 AM
mixed Java + Kotlin is fine, the Kotlin compiler can use the Java tooling API to compile both at the same time
mixed (non-Java JVM language) + (other non-Java JVM language) within the same module will be problematic though
u

udalov

09/14/2020, 11:10 AM
We use intellij-core (a part of IntelliJ Community Edition) to resolve Java source code. In a mixed Kotlin+Java project, Kotlin sources are compiled first, with the Kotlin compiler reading Java sources if necessary. Then Java sources are compiled with javac against the .class files generated by Kotlin. Mixed modules with other languages will therefore not work in this scheme, unless you ensure that there are no circular dependencies between sources of different languages (but in that case, it makes sense to extract parts in different languages to different modules anyway).
s

Strum355

09/14/2020, 12:37 PM
with the Kotlin compiler reading Java sources if necessary.
Am I right in saying this is how the Kotlin compiler can type-check constructs from Java sources used in Kotlin sources? And how much of this functionality is in kotlin-compiler-embeddable?
(on a side note, https://javadoc.io/doc/org.jetbrains.kotlin/kotlin-compiler-embeddable/ and possibly others are very out of date, Im not sure if this is something handled on the jetbrains side of things or if these are community submitted)
u

udalov

09/14/2020, 12:53 PM
There’s no type checking of Java sources involved because all types are explicit in Java. We do need to parse the Java source and resolve types in the signatures. It’s far easier than to type-check function bodies in Java sources, which the Kotlin compiler doesn’t need since they can’t affect call sites.
kotlin-compiler-embeddable
is in fact the full Kotlin compiler with shadow-jared dependencies.
👍 1
I’m not sure what that site’s referring to. Here’s the latest release on the Maven central: https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-compiler-embeddable/1.4.10/jar
s

Strum355

09/14/2020, 1:07 PM
Was looking for hosted javadoc for various org.jetbrains.kotlin packages, javadoc.io were the first I could find but they were very much behind in releases
View count: 2