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

    dalexander

    11/10/2020, 4:43 PM
    Hey I'm working on a compiler plugin in the analysis phase, and I'm doing some annotation processing. I have an annotation with a KtValueArgumentList, and I'm trying to either resolve the value of a contained value argument, or the fully qualified name. I've tried getting the type out of the bindingContext, but it consistently returns null (maybe it's not available during analysis?).
    ContextExpressionEvaluator.getConstant()
    also seems to return null. Any insight into what I could do to resolve the reference to either a fully qualified name or extract the value would be appreciated!
    s
    4 replies · 2 participants
  • n

    Nabil

    11/14/2020, 1:36 AM
    Hi, if my compiler plugin runs on a multiplatform project (jvm with IR & macos), how can I reference common stdlib classes like
    HashMap
    ?
    pluginContext.referenceClass(FqName("kotlin.collections.HashMap"))
    • On JVM returns
    null
    • On Macos (K/N) returns the symbol Since
    HashMap
    is a typealias to
    java.util.HashMap
    I thought using
    pluginContext.referenceTypeAlias(FqName("kotlin.collections.HashMap"))
    could work but it's behaving differently • ON JVM it throws
    AssertionError: Package or class expected: typealias HashMap; for K
    t org.jetbrains.kotlin.ir.declarations.lazy.IrLazyDeclarationBase$createLazyParent$1.invoke(IrLazyDeclarationBase.kt:70)
    • On K/N (macos) it returns
    null
    How can one reference an available common class from the stdlib like
    kotlin.collections.HashMap
    ? The only work around I can see is to test if
    pluginContext.referenceClass(FqName("java.util.HashMap"))
    returns null, which indicates I'm running the compiler plugin within a K/N context and fallback to
    pluginContext.referenceClass(FqName("kotlin.collections.HashMap"))
    ... Any thoughts appreciated 🙂
    s
    1 reply · 2 participants
  • n

    Nabil

    11/18/2020, 10:22 AM
    I'm emitting an
    IrTypeOperatorCallImpl
    instruction with an
    operator = IMPLICIT_NOTNULL
    This works fine on JVM platform, however for K/N it throws
    e: kotlin.NotImplementedError: An operation is not implemented: TYPE_OP type=MyClassFoo origin=IMPLICIT_NOTNULL typeOperand=MyClassFoo
    	at org.jetbrains.kotlin.backend.konan.llvm.CodeGeneratorVisitor.evaluateTypeOperator(IrToBitcode.kt:1351)
    Browsing K/N repo I found that indeed this is not supported
    TODO(ir2string(value))
    is this a known issue? is there a work around this? https://github.com/JetBrains/kotlin-native/blob/master/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/IrToBitcode.kt#L1353
    s
    2 replies · 2 participants
  • g

    groostav

    11/18/2020, 11:19 PM
    is there a discussion of having the compiler do something to convert
    someMap[key]!!...
    into
    someMap.getValue(key)...
    ?
    e
    d
    4 replies · 3 participants
  • p

    PHondogo

    11/26/2020, 8:56 PM
    Hello! I've written Kotlin compiler plugin, that add main method using IrFile.addFunction. in 1.4.20 it was removed. Please, advise me for alternatives.
    s
    1 reply · 2 participants
  • m

    MiSikora

    11/30/2020, 9:53 PM
    I have a question kind of about compiler and kind of about YouTrack. I have a use case where I need to suppress
    ERROR
    and
    HIDDEN
    deprecation level compiler errors for generic parameter on a deprecated class itself. More info here – https://youtrack.jetbrains.com/issue/KT-34480#focus=Comments-27-4558822.0-0. Is this something that could be added? A follow-up question is about YouTrack. I found the linked issue but the person that, I think, was handling it is now banned. How such old-ish and stale issues are handled by JetBrains? Is anyone from JB team notified about it or is there some procedure to bring issues up?
    m
    3 replies · 2 participants
  • f

    Foso

    12/06/2020, 6:40 PM
    Hi, is there a method to parse a File into a IrFile ? (I know that i can get IrFiles with IrGenerationExtension, but that compile phase is too late for my usecase)
    s
    z
    7 replies · 3 participants
  • w

    Wietlol

    12/07/2020, 10:36 PM
    I am trying to explore LLVM a bit, but I fail to find good examples of how to use it. I heard Kotlin/Native uses LLVM as the back-end of its compiler so I thought about taking a look at the https://github.com/JetBrains/kotlin-native repository to see if I could find how the Kotlin/Native compiler generates LLVM IR and which IR instructions it uses. However, I am totally lost in that project and have no clue where to actually look for what I want to find. Can anyone point me to where the LLVM IR generation is and how the compiler invokes it? And couldd I perhaps use the Kotlin/Native compiler itself as a library to generate the LLVM IR for me?
    r
    1 reply · 2 participants
  • r

    raulraja

    12/08/2020, 5:16 PM
    Hi, I was wondering if this is expected behavior or I should file a bug. I looked in youtrack but could not find a similar one. https://pl.kotl.in/3m3uiVtjK
    Type mismatch resolving functions with the same name when using lambda arguments
    d
    v
    4 replies · 3 participants
  • m

    melatonina

    12/10/2020, 7:25 PM
    The cause is this other exception:
    java.lang.IllegalStateException: Error type encountered: [ERROR : <ERROR FUNCTION RETURN TYPE>] (DeferredType)
    It's not an informative message, to my eyes, unfortunately.
    r
    4 replies · 2 participants
  • l

    Liyue

    12/11/2020, 2:51 AM
    Hi, i try to get all methods from a
    ClassDescriptor
    , but when i use
    (AInstance as ClassDescriptor).unsubstitutedMemberScope.getContributedDescriptors().filterIsInstance<FunctionDescriptor>()
    will get all default functions, such as
    toString
    euqals
    . Is there any better method to get all member methods including static methods?
    2 replies · 1 participant
  • i

    Iaroslav Postovalov

    12/13/2020, 11:27 AM
    Are there any examples how to decompile FIR (FirElement) to source code String?
    d
    2 replies · 2 participants
  • l

    Liyue

    12/14/2020, 6:02 AM
    Can we get the relevant information of whether a method is a static or normal from an instance of
    JavaMethodDescriptor
    ?
    u
    2 replies · 2 participants
  • a

    acando86

    12/16/2020, 2:34 PM
    Apologies if OOT in this channel or if there is an existing issue already that i couldn't find , but i would like to understand if the following behaviour is expected. Here is a MWE to illustrate my problem.
    fun minimalExample(
      ids : List<Long>,
      details : Map<String, Boolean>
    ) : List<Boolean?> =
      ids.map { id -> details.get(id) }
    I'm mapping over a list of
    Longs
    and for each
    Long
    i try to access the corresponding value from a key-value map; the map however here is of type
    Map<String, Whatever>
    , not
    Map<Long, Whatever>
    I've done that on purpose so that when writing
    details.get(id)
    the types don't match I would have expected the compiler to throw a compilation error, something like
    type mismatch: inferred type is Long but String was expected
    Instead i can compile the code and run it (obviously at runtime there is jvm type erasure on generic and details.get(id) will always return null in this case). there is a warning
    warning: type inference failed. The value of the type parameter K should be mentioned in input types (argument types, receiver type or expected type). Try to specify it explicitly.
    the problem with this warning is two fold: 1. it's error prone. I can handle all warnings as errors, or set a linter, but i would have expected the inference to work just fine in this example 2. there seems to be no obvious way to me to provide the extra information that the compiler would need in order for the type inference to work. is this behaviour expected or is an issue?
    m
    a
    14 replies · 3 participants
  • n

    nemi

    12/23/2020, 8:14 AM
    Hi, I'm working on a kotlin compiler plugin. One of the tasks of the plugin is to replace certain interfaces with a class. E.g.:
    inteface Greeting {
      fun greet()
    }
    Would be transformed into a class replacing the interface:
    class Greeting {
      fun geet() {
        println("Hello, World!")
      }
    }
    When trying to figure out whether I can to this and mostly how, I looked at [arrow-meta](https://github.com/arrow-kt/arrow-meta). I see they accomplish replacing/renaming pieces of kotlin code in a
    AnalysisHandlerExtension
    . They also build their own AST and have their own writer to write the modified tree into a file. So I though instead of relying on arrow-meta I thought I'd use the PSI api to copy, modify and get the text of modified files. However it seems that in the compiler some pieces of PSI is not available. Most importantly when I try to delete and element from the tree I get the following exception:
    e: java.lang.NullPointerException
            at org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.CodeEditUtil.saveWhitespacesInfo(CodeEditUtil.java:122)
            at org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.CodeEditUtil.removeChildren(CodeEditUtil.java:134)
            at org.jetbrains.kotlin.com.intellij.psi.impl.source.codeStyle.CodeEditUtil.removeChild(CodeEditUtil.java:49)
            at org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.CompositeElement.deleteChildInternal(CompositeElement.java:451)
            at org.jetbrains.kotlin.com.intellij.extapi.psi.ASTDelegatePsiElement.deleteChildInternal(ASTDelegatePsiElement.java:346)
            at org.jetbrains.kotlin.com.intellij.extapi.psi.ASTDelegatePsiElement.delete(ASTDelegatePsiElement.java:330)
    Looking at
    CodeEditUtil
    I know that the
    NullPointerException
    is raised in this part
    public static void saveWhitespacesInfo(ASTNode first) {
      ...
      setOldIndentation((TreeElement)first, IndentHelper.getInstance().getIndent(file, first));
    }
    Because
    IdentnHelper.getInstance()
    returns null.
    public abstract class IndentHelper {
      public static IndentHelper getInstance() {
        return ApplicationManager.getApplication().getService(IndentHelper.class);
      }
      ...
    }
    And indeed trying to get
    IndentHelper
    as service returns null in my plugin. So now I'm wondering if it is possible to install an instance if this service out side of the IDE to be able to manipulate PSI in a kotlin compiler plugin. Alternatively I'd be also grateful is someone could provide me with the highlights on an alternative approach to achieve my goal.
    d
    r
    5 replies · 3 participants
  • i

    Iaroslav Postovalov

    12/26/2020, 9:01 PM
    Are there any IrDeclaration implementations without visibility?
    u
    1 reply · 2 participants
  • j

    Jonathan Gerrish

    12/28/2020, 6:10 PM
    Hi all. I'm trying to write a compiler plugin that tracks which jars dependencies are loaded from. Is an `AnalysisHandlerExtension`the right kind of extension to do this? I'm having trouble finding an API that is able to tied a KtType back to the jar it was loaded from. Any pointers appreciated 🙂
    s
    16 replies · 2 participants
  • s

    Sasha Shpota

    01/04/2021, 9:41 AM
    Hi all! I need help. I am creating a compiler plugin in which I adjust property declarations if they are annotated with a specific annotation. Problem: I need to filter properties by annotations. At the moment, I have access to
    org.jetbrains.kotlin.psi.KtProperty
    , form which I need to get annotations. So far, I found a way to do it like this:
    property.annotationEntries.any {
            it.typeReference
                ?.typeElement
                ?.safeAs<KtUserType>()
                ?.referencedName == "MyAnnotation"
        }
    But
    referencedName
    doesn't return a fully qualified name (
    MyAnnotation
    instead off
    com.example.MyAnnotation
    ) Question: How to check if a
    KtProperty
    is annotated with a particular annotation?
    👀 2
    i
    5 replies · 2 participants
  • z

    Zac Sweers

    01/05/2021, 7:58 PM
    Is there a canonical way to request exposing an API in IR? I'd like to reuse some code from data class generation but it uses an internal
    GeneratorContext
    API that looks pretty generally useful
    ➕ 3
    r
    1 reply · 2 participants
  • m

    murdock

    01/10/2021, 1:18 AM
    Heyo, how would one build a IrCall with a vararg as value parameter?
    r
    4 replies · 2 participants
  • r

    raulraja

    01/11/2021, 12:51 PM
    Hi there!, I’m trying to get a hold of the descriptor or IR node for
    kotlin.Int.plus
    . I’m currently using with no luck the following code which returns other
    plus
    functions like the ones for collections, BigInteger and String but nothing for
    Int
    builtIns.builtInPackagesImportedByDefault.flatMap {
        it.memberScope.getContributedDescriptors { true }
    }
    Any help on how to get a hold of those descriptors is appreciated. Thanks!
    d
    4 replies · 2 participants
  • c

    Cedric Hippmann

    01/12/2021, 12:56 PM
    Hi all. I'm currently writing a compiler plugin which needs to extract the assignment of certain properties from the source files. The problem is i always need to be able to extract those assignments for all files. But when the current run is incremental, i only get the new/changed files. My current way of doing this is to provide a
    DeclarationChecker
    which extracts the
    assignmentPsi
    from the `PropertyDescriptor`'s. Is there another hook or a better way with which i can do this for all source files not just those that have changed since the last run? I just need this to work on the JVM.
    a
    5 replies · 2 participants
  • p

    pajatopmr

    01/15/2021, 4:48 AM
    Truth in advertising: I know zip about the compiler but I want and need to know a lot more. My goal is to learn enough about the compiler to work on a Kotlin LSP server and do useful things. I could tell you more but you'd likely die of boredom if I elaborated. Please excuse my abuse/misuse of terminology as I learn and do direct me to code/documentation/etc so I can ask better questions. So here's the most direct question I can come up with: if I have a callable reference node (PsiElement), is there a way I can access the associated declaration at the time I see the reference node? I'm guessing that I can since the compiler must know about a declaration before it can label an identifier as a callable reference. The callable reference is a "println" in case it matters.
    r
    2 replies · 2 participants
  • h

    holgerbrandl

    01/16/2021, 8:20 PM
    It may be stupid/newbie question, but can I use contracts to check if method arguments are < 0?
    fun foo(param:Int) {
    // old school, but could we use a contract here to get compiler error at callsite for foo(-1) instead?
    require(param >1)
    
    // do something great
    println(param)
    }
    d
    r
    +1
    12 replies · 4 participants
  • s

    Sasha Shpota

    01/18/2021, 11:32 AM
    Hi everybody! I am trying to modify annotations of a property getter. The idea is that I add a new annotation to a property if conditions match. I am overriding
    IrElementTransformerVoidWithContext.visitPropertyNew()
    and my code looks somewhat like this:
    override fun visitPropertyNew(declaration: IrProperty): IrStatement {
        declaration.getter?.let {
            it.annotations = it.annotations + aNewAnnotationEntry
        }
        return super.visitPropertyNew(declaration)
    }
    Problem: This works well for all properties but not for properties of data classes. Question: How do I add an annotation to a getter of a property of a data class declared in its constructor?
    👀 2
    r
    9 replies · 2 participants
  • n

    neworldlt

    01/18/2021, 11:36 AM
    Where could I find a jar of sources or Javadoc for
    kotlin-embeddable-compiler
    ? Shipped version in maven contains empty jars: https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-compiler-embeddable/1.4.21/
    r
    4 replies · 2 participants
  • j

    jimn

    01/19/2021, 11:50 AM
    when is EOL on kotlin requiring 1.6,7,8,9 specific jdk support to build? is 1.8 good enough ? or jdk 11 ?
    d
    6 replies · 2 participants
  • j

    jimn

    01/20/2021, 1:35 PM
    how many iterations until "Many programming languages have self-hosted implementations: compilers that are both in and for the same language. Such languages include Ada, BASIC, C, C++,[4] C#,[5] ClojureScript,[6] CoffeeScript, Crystal, D, Dylan, F#, FASM, Forth, Gambas, Go, Haskell, HolyC, Java, Lisp, Modula-2, OCaml, Oberon, Pascal, Python, Rust, Scala, Smalltalk, TypeScript, Vala, and Visual Basic"+=" Kotlin"
    i
    2 replies · 2 participants
  • e

    eekboom

    01/21/2021, 3:39 PM
    👋 Is it possible to write a compiler plugin that adds a Builder pattern a la lombok's @Builder? I understand that it's not needed if you stay in the Kotlin world, but for migrating a large codebase that uses lombok to Kotlin, it would help a lot if you could use builders in Java to create instances of Kotlin classes.
    :yes: 1
    r
    s
    8 replies · 3 participants
  • k

    Kroppeb

    01/21/2021, 6:06 PM
    Has anyone already tried to use IR to compile Kotlin to a different language yet?
    d
    r
    +2
    10 replies · 5 participants
Powered by Linen
Title
k

Kroppeb

01/21/2021, 6:06 PM
Has anyone already tried to use IR to compile Kotlin to a different language yet?
And if so, was it to a language that oop, or to a language that is more restrictive?
d

Dominaezzz

01/21/2021, 6:59 PM
JavaScript lol
r

raulraja

01/21/2021, 9:38 PM
@Kroppeb not sure if it helps but I’m using it to compile to a different IR expressed in lisp but not as binary target beyond JVM
k

Kroppeb

01/21/2021, 10:21 PM
mmh, How can I tell the compiler to just compile to IR? Cause to me it seems I have to compile to a certain target and have a plugin to create the desired extra files.
Which is annoying
g

gildor

01/21/2021, 11:56 PM
I don't think it's supported out of the box, worth to report a feature request, but in general it looks as a new target platform for Kotlin and not sure that there is simple way. You can start from checking how WASM target is doing this
r

rnett

01/25/2021, 10:58 PM
Eventually I think KLibs will be serialized IR I think, it's been mentioned in a few places (Kotlin 1.4 event multiplatform talk maybe?) that they want the ability to publish purely common libraries, which would require it. See https://kotlinlang.org/docs/reference/native/libraries.html
g

gildor

01/26/2021, 7:38 AM
Well, yes, hopefully there is will be support of IR-based dependencies for Kotlin which is great feature, but generating different language from this raw IR is possible in theory, but probably not the most efficient way, you really need integration with compiler to get all the code of backend to read, interpret it and generate some output, so this why I think it is a lot more efficient to integrate with compiler, which has all the facilities to create new platforms (K/N and especially WASM targets are good show cases of it, because already based on IR)
r

rnett

01/26/2021, 11:56 PM
Yeah, if you want to add another platform, I'd definitely do it that way. I meant more that if you wanted to take an already-compiled kotlin lib and convert it to another language, I would think you could use the compiler artifact to deserialize the IR from a klib and work from there.
g

gildor

02/02/2021, 2:57 AM
also one point, if you just need raw IR, compiler plugin API is probably the easiest way to do that now and it already works, not need to generate IR dependency (after all it’s just intermediate output) and those dependencies are not supported yet
View count: 1