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

    charleskorn

    05/08/2021, 1:21 AM
    On upgrading to Kotlin 1.5, I’m getting
    e: java.lang.IllegalStateException: not identifier: <init>
    errors while compiling (example). Is this a known issue?
    u
    • 2
    • 2
  • d

    Daniel Kuschny

    05/08/2021, 1:14 PM
    Hey everyone. 👋 I joined here in the hope to reach some of the Kotlin compiler experts. I'm following up on my post here. Long story short: is there a way I can analyze why the Kotlin compiler takes so long to compile the same codebase which compiles in part of the the time on other compilers like C#? It seems quite long that my codebase compiles in 30s for TypeScript (👍), 1:15min for C# (👍) but 4:48min for Kotlin (👎). I just upgraded to Kotlin 1.5 in the hope to get a speed up but it's basically the same speed as with 1.4.x. Example compilation here.
    i
    f
    e
    • 4
    • 16
  • z

    Zac Sweers

    05/08/2021, 6:44 PM
    is there any expected performance penalty for enabling
    -Xextended-compiler-checks
    ?
    👀 1
    r
    • 2
    • 3
  • y

    Youssef Shoaib [MOD]

    05/08/2021, 7:12 PM
    Hello there! I've heard that the plan is to eventually disallow suppressing certain compiler errors (like "INVISIBLE_MEMBER" and "INVISIBLE_REFERENCE" for example) which is absolutely understandable, but would compiler plugins still be able to suppress certain compiler errors one way or another? Currently, I'm generating some sources in an AnalysisHandler (which I know will eventually be deprecated don't worry but I'm just using it for now and the logic should be the same for the future) based on existing sources and shadowing them using
    @Suppress("REDECLARATION")
    but I'm wondering if maybe there's a better way to do that (like a custom call resolved I guess) and if eventually this trick will be completely disallowed
    r
    u
    • 3
    • 6
  • y

    Youssef Shoaib [MOD]

    05/08/2021, 7:49 PM
    Different question. Are there any current plans to eventually use JVM IR for inlining? or just any plans to include serialised JVM IR in published jars? Because that can be immensely useful for compiler plugins that need to use IR from external sources. For example, I'm currently performing inlining manually on the IR level, and so on the JVM I have to do a few hacks with finding the sources jar for a file and compiling that source to use its IR, but if I had access to serialised IR, I can just deserialise that and inline it directly.
    👀 1
    u
    • 2
    • 3
  • d

    dimitar_

    05/13/2021, 4:17 PM
    Hey all 🙂 I’m new to Kotlin compiler plugins and hope this is the right place to ask. I’m playing with the new IR compiler plugins. I created a simple test, that adds a function to an annotated class. The function just calls
    println("I'm here");
    I can compile the class and when I try to use
    kotlinc
    to compile another class that calls the generated function, I get:
    kotlinc -classpath . test.kt
    test.kt:2:10: error: unresolved reference: generatedFunction
      Main().generatedFunction()
    But when I do the same with
    javac
    , everything is ok. I can also run the class and I get the desired output
    java Test
    I'm here
    Any pointers would be highly appreciated 🙂 p.s. Is there any documentation about writing compiler plugins with IR out there?
    r
    • 2
    • 10
  • d

    dimsuz

    05/15/2021, 12:07 PM
    Hi! Why is type inference failing here? To my eyes it has all the info it needs to infer the type...
    class Builder {
      fun <R> build(action: (R) -> R): Builder = this
    }
    
    fun main() {
      val value = 3
      Builder()
        .build { value } // compiler error: not enough information to infer type variable R
    }
    That is: lambda is returning
    Int
    therefore
    R
    is
    Int
    UPD: this is kotlin 1.5.0
    i
    r
    +2
    • 5
    • 10
  • r

    rnett

    05/16/2021, 12:04 AM
    Is there a way, via gradle configuration or a compiler plugin, to get the compiler to generate a klib for JVM? I want to use the IR after compilation (creating bindings for a compiler plugin to use), and while I could use a plugin to write those bindings to an external file, if I can just use the klib I won't have to worry about incremental compilation.
    d
    u
    • 3
    • 3
  • t

    Tristan Blakers

    05/16/2021, 2:18 PM
    apologies if this is the wrong place to ask. I've searched google and YouTrack and found nothing remotely related. Am upgrading a JVM/JS project to 1.5.0, and getting the below stack trace when the JS is compiling in one of my modules. It's tough to even know where to start, because it doesn't give a hint about the offending file, and the compiler debug breakpoints aren't hitting. Any debug hints appreciated
    d
    • 2
    • 2
  • a

    andi

    05/16/2021, 3:39 PM
    Hey, I debugged KT-29088 a bit (trying to learn how the compiler works) and I think the root cause is that CompareTo only implements comparison of
    Char
    ,
    Byte
    ,
    Short
    ,
    Int
    ,
    Long
    ,
    Float
    and
    Double
    . And for all other types, it will fallback to Int. However
    CompareTo
    is registered for all possible combinations of primitives, hence also for Boolean::compareTo(Boolean). I'm unsure if there is a smart trick/optimization behind using
    kotlin.jvm.internal.Intrinsics::compare(Int, Int)
    also for
    Boolean::compareTo(Boolean)
    ?
    • 1
    • 3
  • r

    Rob Elliot

    05/17/2021, 7:56 AM
    Hi - just read this article about the need to add
    @JvmSynthetic
    to
    internal
    members to properly hide them from Java: https://medium.com/scalereal/hide-internal-members-of-kotlin-module-from-jvm-c7730507fb17 which informed me of
    @JvmSynthetic
    https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.jvm/-jvm-synthetic/ which in turn led me to
    ACC_SYNTHETIC
    https://docs.oracle.com/javase/specs/jvms/se15/html/jvms-4.html Is there a reason why the compiler with the JVM backend doesn’t just add the
    ACC_SYNTHETIC
    access_flag to
    internal
    methods without needing to add the noise of an extra annotation?
    i
    • 2
    • 3
  • s

    Strum355

    05/19/2021, 7:23 PM
    I saw in the Kotlin roadmap that the compiler frontend is being reworked. Does this imply that the API is going to have significant breaking changes?
    e
    r
    +3
    • 6
    • 14
  • d

    Dominaezzz

    05/23/2021, 9:50 AM
    Has anyone considered a compiler plugin for mocking?
    s
    r
    • 3
    • 11
  • g

    groostav

    05/23/2021, 10:37 PM
    Hey guys, I've got a fairly basic math language I've expressed with antlr, it works and runs, but now I want to do some transcoding into a lisp-like language (specifically, my custom math language that supports things like
    x*y^z + cos(f)
    I want to translated into smt-lib2). I've read the compilers book in school and have used ANTLR professionally for some time, and I can probably hack this out with an antlr visitor and creating classes as the occur to me along with a good whack of string mangling, but I'm willing to bet somebody smarter than me has some nice compiler/code-generator tutorials/tools that would make my life a fair bit easier. Has anybody here done something similar and have some suggested reading?
    r
    • 2
    • 1
  • r

    rnett

    05/23/2021, 11:18 PM
    I'm having trouble (
    NoClassDefFoundError
    errors) trying to use a library in a native compiler plugin (i.e. using
    kotlin-compiler
    instead of
    kotlin-compiler-embeddable
    . Said library also uses
    kotlin-compiler
    , and I'm depending on it using
    implementation
    , which works fine for the non-native compiler plugin, but when I try to use something from the library in the native plugin I get
    NoClassDefFoundError
    . Do I need to shade it in myself?
    s
    • 2
    • 3
  • e

    evanchooly

    05/25/2021, 8:55 PM
    and, yes, i'm probably mucking in things I shouldn't and I'm currently reworking it all on top of the antlr4 grammars so I don't need to rely on compiler internals but I was hoping that with the plugins that the compiler offers there'd be a nicer way to do what I'm trying to do.
    r
    b
    u
    • 4
    • 9
  • j

    Jan Skrasek

    05/28/2021, 7:11 AM
    Does using
    internal
    modifier cause some optimized compilation in a way that compiler knows it isn't used from other dependent modules and skips the check "in them"?
    f
    g
    • 3
    • 5
  • r

    raulraja

    05/31/2021, 1:55 PM
    Hello everyone!, I was looking at
    org.jetbrains.kotlin.fir.extensions.FirExtensionRegistrar
    and looking into how to integrate with plugins that depend on
    org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
    and
    org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
    . I see
    AllOpen
    and others are connected to the new FIR frontend and I was hoping to run some compiler plugin tests and work on the FIR support for arrow meta. I have a couple of questions that came up while I was working on this. Here it goes in case anyone can help. 1. The
    FirExtensionRegistrar
    unlike the
    ComponentRegistrar
    is not an interface but an abstract class and it requires a separate lifecycle. Once instantiated for regular CLI plugins and another for the FIR style of subscription. Did I miss-understood this or is there a way to integrate this with existing compiler plugins based on the
    ComponentRegistrar
    ? 2. Even when declaring both of those extensions and enabling FIR with
    configuration.put(CommonConfigurationKeys.USE_FIR, true)
    the override for the FIR plugin`override fun ExtensionRegistrarContext.configurePlugin(): Unit` never gets called, Is there something else needed to enable FIR beside that flag? If anyone has had success testing the FIR extension points or could provide any guidance or example as to how to enable them I’d very much appreciate it. Thanks!
    d
    • 2
    • 9
  • d

    dmitriy.novozhilov

    05/31/2021, 4:24 PM
    Hey folks. I know that there are people how are interested in new FIR compiler and want to discover how it works, so I want to share with you some information about FIR itself and kotlin project environment setup so you can inspect, debug and even modify FIR locally for your experiments. Actually, this is only way to interact with FIR right now, since compiler API for FIR is postponed (see thread above) Details in :thread-please:
    :kotlin-intensifies: 16
    👍🏾 1
    👍🏼 3
    👍 27
    💯 17
    m
    g
    • 3
    • 19
  • s

    scaventz

    06/03/2021, 1:25 PM
    fun interface Foo : () -> Unit
    
    fun interface Foo1 : Foo
    fun interface Foo2 : Foo
    
    fun test(foo: Foo2) {
        println(foo)
    }
    
    fun main() {
        val instance = object : Foo1 {
            override fun invoke() {
            }
        }
        test(instance) // is this allowed by design?
    }
    Maybe I'm not smart enough to understand why this is allowed, it makes me feel confused, is there any particular reason to support this behavior?
    r
    e
    • 3
    • 4
  • p

    Peter

    06/03/2021, 6:01 PM
    Expected an compiler error, but it didn't came 😉 Is this expected behavior?
    class Dummy {
    
        // Define as read-only access map
        private val buffers: Map<String, String>
    
        init {
            buffers = mutableMapOf()
    
            // Unexpected, no error
            buffers["test"] = "hello"
        }
    
        fun dummy2() {
    
            // Not allowed, as expected
           buffers["test"] = "hello"
        }
    
    }
    e
    • 2
    • 2
  • c

    CLOVIS

    06/11/2021, 3:25 PM
    I hope this is the correct place to ask for Gradle issues. I am using the
    kotlin("js")
    plugin, 1.5.10, Kotlin DSL, and I want to change the default timeout.
    js {
    	browser {
    		testTask {
    			useKarma {
    				useChromiumHeadless()
    				timeout.set(??)
    			}
    		}
    	}
    }
    According to the Gradle documentation:
    task myTask {
    	// java.time.Duration 
    	timeout = Duration.ofMinutes(10)
    }
    However if I add write:
    timeout.set(java.time.Duration.ofMinutes(10))
    Then IntelliJ & Gradle complain with
    Unresolved reference: time
    timeout
    doesn't have any overloads that would accept
    kotlin.Duration
    or even
    groovy.Duration
    . Is it even possible currently to set the timeout with the Kotlin DSL?
    r
    • 2
    • 2
  • m

    mcpiroman

    06/15/2021, 7:23 AM
    [Source, IR BE]: Is there any reason why some of the Impls of the IR elements are in ir.tree module and others in ir.tree.impl? The latter seem to only differ in that they contain and override IrFactory (also dunno why). In FIR, all Impls seem to lay in the tree module (but it is auto-gen, I know).
    d
    b
    u
    • 4
    • 10
  • j

    Jorge Castillo

    06/19/2021, 1:52 PM
    Hi 👋 what use case does this error report on? Seems to be related to annotated inline lambdas with annotations using non source retention (any annotations that survive until the output binaries), maybe related to closure capturing but not 100% sure.
    • 1
    • 3
  • m

    Marcello Lelio Albano

    06/19/2021, 4:51 PM
    Hi, is there a way to read the full method signature from a KtNamedFunction? Was wondering if there is a utils method or something like that. Thanks!
    s
    • 2
    • 3
  • b

    Ben Dodson

    06/24/2021, 4:31 PM
    Hi all 🙂 We’re trying to upgrade to Kotlin 1.5, but are a bit stuck. We have a number of places that create a
    private typealias
    , and then use that alias in a public method. This seems to work in Gradle, but not in our Bazel setup. My main question is, is this valid code and a bug in our Bazel setup, or should we not expose a private typealias in a public api?
    r
    g
    • 3
    • 10
  • t

    themarketka

    06/27/2021, 7:08 PM
    Hey guys. I’m running into a particular issue after updating the Kotlin plugin in AS to 1.5.20. The surrounding code is probably irrelevant, it’s the same error appearing in multiple occurrences of such code. I got a data class that looks like this:
    data class MapObjects(
        val map: com.google.android.gms.maps.GoogleMap,
        val markerManager: com.google.maps.android.collections.MarkerManager,
        val markerCollection: com.google.maps.android.collections.MarkerManager.Collection,
    )
    The
    MarkerCollection.Collection
    is a Java nested/inner class, not a static one. After the update to Kotlin 1.5.20 (keeping runtime dependencies on 1.5.0), it compiles, but IDE complains about code like this:
    val mapObjs: MapObjects = mapObjects // lateinit var access
    mapObjs.markerCollection.clear()
    Basically anything accessing the
    markerCollection
    shows
    Internal Error occurred while analyzing this expression
    . I reported it from within IDE already. Funny detail though: when I update runtime dependency to 1.5.20, it outright crashes while compiling:
    org.jetbrains.kotlin.backend.common.BackendException: Backend Internal error: Exception during file facade code generation
    . Based on that I do not believe it’s related to Android Studio in particular. Please send help, and if I should, include where/how do I file this in the Kotlin’s issue tracker at https://youtrack.jetbrains.com/issues/KT.
    kotlin issue stacktrace.txt
    r
    • 2
    • 4
  • d

    dimsuz

    06/28/2021, 11:11 AM
    it seems like inline classes don't always get boxed when used as generics (contrary to what docs say). Is this a bug or expected behavior?
    inline class InlinePayload(val id: String)
    
    fun <T> test(t: T): T {
      return t
    }
    
    val (p1, p2) = listOf(test(3))
      .zip(
        listOf(test(InlinePayload("a"))), // (1)
        ::Pair)
      .first()
    
    println(p2.id) // (2) EXCEPTION!
    It seems that
    (1)
    creates a
    List<String>
    rather than
    List<InlinePayload>
    and then
    (2)
    crashes with
    class java.lang.String cannot be cast to class ru.example.app.InlinePayload (java.lang.String is in module java.base of loader 'bootstrap'; ru.example.app.InlinePayload is in unnamed module of loader 'app')
    d
    • 2
    • 3
  • s

    Strum355

    06/29/2021, 1:26 PM
    Is anyone else having issues attaching sources for kotlin compiler? I understand kotlin-compiler-embeddable doesn't contain sources, but even when I attach kotlin-compiler-sources.jar I dont get good results. Example: while debugging if I Go to Type Source for a
    DeserializedTypeAliasDescriptor
    , it brings me to the decompiled class file. Meanwhile a symbol search gives the correct Kotlin source file
    DeserializedMemberDescriptor.kt
    . Any ideas? I have
    compileOnly(kotlin("compiler-embeddable"))
    in my gradle file, and
    relocate("com.intellij", "<http://org.jetbrains.kotlin.com|org.jetbrains.kotlin.com>.intellij")
    when creating a JAR, but I dont believe that is relevant here as the package name is the same in both source and class file.
    r
    r
    • 3
    • 4
  • s

    Strum355

    06/29/2021, 5:56 PM
    I have the following code in my top level
    build.gradle.kts
    file in order to test my compiler plugin (without the more "recommended" route of creating a gradle plugin), but Im not seeing it working for multi-project gradle projects. The plugin seems to only get invoked for a single sub-project, as per the screenshot only displaying output mentioning the sub-project with a single Kotlin file (I am printing out the list of KtFile virtualPath in the
    analysisCompleted
    method). Project can be found here https://github.com/Strum355/lsif-kotlin (the snippet below would be in the root
    build.gradle.kts
    )
    allprojects {
        tasks.withType<KotlinCompile> {
            val targetroot = File(this@allprojects.buildDir, "semanticdb-targetroot")
            kotlinOptions {
                freeCompilerArgs = freeCompilerArgs + listOf(
                    "-Xplugin=/home/noah/Sourcegraph/lsif-kotlin/semanticdb-kotlinc-1.0-SNAPSHOT-all.jar",
                    "-P",
                    "plugin:com.sourcegraph.lsif-kotlin:sourceroot=${this@allprojects.projectDir.path}",
                    "-P",
                    "plugin:com.sourcegraph.lsif-kotlin:targetroot=${targetroot}"
                )
            }
        }
    }
    • 1
    • 1
Powered by Linen
Title
s

Strum355

06/29/2021, 5:56 PM
I have the following code in my top level
build.gradle.kts
file in order to test my compiler plugin (without the more "recommended" route of creating a gradle plugin), but Im not seeing it working for multi-project gradle projects. The plugin seems to only get invoked for a single sub-project, as per the screenshot only displaying output mentioning the sub-project with a single Kotlin file (I am printing out the list of KtFile virtualPath in the
analysisCompleted
method). Project can be found here https://github.com/Strum355/lsif-kotlin (the snippet below would be in the root
build.gradle.kts
)
allprojects {
    tasks.withType<KotlinCompile> {
        val targetroot = File(this@allprojects.buildDir, "semanticdb-targetroot")
        kotlinOptions {
            freeCompilerArgs = freeCompilerArgs + listOf(
                "-Xplugin=/home/noah/Sourcegraph/lsif-kotlin/semanticdb-kotlinc-1.0-SNAPSHOT-all.jar",
                "-P",
                "plugin:com.sourcegraph.lsif-kotlin:sourceroot=${this@allprojects.projectDir.path}",
                "-P",
                "plugin:com.sourcegraph.lsif-kotlin:targetroot=${targetroot}"
            )
        }
    }
}
Think Ive found the issue, a subproject was overriding
freeCompilerArgs
🤦‍♂️
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions {
    freeCompilerArgs = listOf("-Xinline-classes") // instead of freeCompilerArgs + listOf("-Xinline-classes")
}
👌 1
View count: 4