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

    pajatopmr

    01/22/2021, 1:05 AM
    I gather that there are multiple compiler apis. Where can I find information about their names and documentation (javadoc would be good)? Especially the api for which KtElement is found.
    j
    r
    • 3
    • 3
  • s

    Sasha Shpota

    01/24/2021, 4:01 PM
    Hi there, Do you know any comprehensive guide on publishing a compiler plugin? I would appreciate any suggestions, gotchas or examples. I want to publish a plugin which would consist of a Gradle plugin + compiler plugin itself, and I am not sure I have a good understanding how to do it right.
    m
    • 2
    • 2
  • t

    tschuchort

    01/26/2021, 4:38 PM
    I have a question about the semantics of the
    javaSourceRoots
    compiler option. Both
    KaptOptions
    and
    K2JVMCompilerArguments
    have a
    javaSourceRoots
    member. So far I have been passing both paths to Kotlin source files and Java source files as
    K2JVMCompilerArguments.freeArgs
    to the compiler and it has worked fine for the most part. Now we have noticed a problem that nested classes in Java sources can not be resolved by compiler plugins. This problem seems to go away when
    javaSourceRoots
    is set to the parent directory where the Java source files are located, but not when paths to the Java source files directly are added to
    javaSourceRoots
    . 1. Why can we give the compiler direct paths to Kotlin files but all the Java files have to be located in the same directory? We can see that the same parameter in
    KaptOptions
    accepts paths to files and not to a parent directory: https://github.com/JetBrains/kotlin/blob/e2521718ddef33d25158032dee649b1fa6f5b73a/[…]t3/kapt3-compiler/src/org/jetbrains/kotlin/kapt3/Kapt3Plugin.kt 2. Why is this option needed at all? The
    K2JVMCompiler
    is able to find and compile Java sources without it, but apparently not nested classes?
    u
    • 2
    • 1
  • j

    Jan Skrasek

    01/27/2021, 7:55 AM
    Is there a way to disallow implicit return type? It seems to be similarly important as
    allWarningsAsErrors
    or
    explicitApi()
    . Or at least some lint anywhere? Thanks.
    r
    • 2
    • 2
  • g

    gammax

    01/29/2021, 5:40 PM
    I found an “interesting scenario” for the 
    compiler-embeddable
     . I would like to get some opinions on it, understand if it’s a bug, where to report it and eventually push a fix upstream. The issue happened on one of our #detekt rule (here the patch on our end) The snippet to reproduce is:
    import com.sample.function.from.outside
    
    fun test() {
        val a = outside()
        val b = a?.plus(42)
    }
    If the external function is not provided during the compilation, the Kotlin compiler is raising an 
    UNNECESSARY_SAFE_CALL
     on 
    a?.plus
    . The type of 
    a
     is 
    org.jetbrains.kotlin.types.ErrorType
     . My hunch is that the compiler should not report this error if they information on the type is missing.
    d
    • 2
    • 7
  • k

    Karlo Lozovina

    02/01/2021, 4:01 PM
    I have a pretty simple method definition:
    private fun getUriForCommand() = URI(
        when (this) {
            is FooBar -> "<http://www.google.hr>"
        }
    )
    which seems to crash the compiler
    e: org.jetbrains.kotlin.util.KotlinFrontEndException: Exception while analyzing expression at
    Could this be a compiler bug?
    d
    • 2
    • 4
  • m

    Michal Harakal

    02/02/2021, 6:51 PM
    Is there a way to disable String templates evaluation in raw string? Other then construct from official docs
    val price = """${'$'}9.99"""
    ? My use case would be embedding of "kotlin source code as string" in custom DSL(similar to
    kotlinx.html
    tag
    sunsafe {raw { """ Kotlin/Any Language code snippet here """}})
    g
    • 2
    • 3
  • k

    kevin.cianfarini

    02/03/2021, 11:16 PM
    why does the compiler eagerly generate wrappers for value/inline classes Wouldn't it make more sense to only generate them when necessary? Like being used with generics?
    i
    k
    • 3
    • 6
  • m

    Marc Knaup

    02/04/2021, 6:33 PM
    How do I know if my build really uses the JVM IR compiler? I’ve compiled so many libraries without any issues that I’m skeptical that my JVM IR setup is correct 😄
    k
    w
    u
    • 4
    • 9
  • w

    wasyl

    02/05/2021, 8:49 AM
    Originally asked in #coroutines but turns out coroutines are irrelevant 🙂 I have a question about the generated code: why does the compiler generate an additional variable when a variable spanning two lambdas is used? For example this code:
    fun test() {
        var foo: Foo? = Foo()
        println(foo)
        runBlock { foo = null }
    }
    
    private fun runBlock(block: () -> Unit) {
        block()
    }
    
    class Foo
    So I have
    var foo
    , which I use in
    println()
    and then null it out in another lambda. The compiler generates the following (decompiled) code:
    final ObjectRef foo = new ObjectRef();
    foo.element = new Foo();
    Foo var2 = (Foo)foo.element;
    boolean var3 = false;
    System.out.println(var2);
    Note the
    Foo var2 = (Foo)foo.element;
    which is used in
    println
    . It is somewhat unexpected, e.g. if
    Foo
    is heavy I may want it to be GC-ed after
    foo = null
    is executed. It won’t be, because
    var2
    is keeping it. Why is necessary that
    var2
    exists, and would it make sense to clear it after it’s used?
    i
    • 2
    • 34
  • m

    Marc Knaup

    02/05/2021, 10:04 AM
    Is there a compiler flag to suppress an error in the entire project? I have hundreds if not thousands of false-positive
    PRE_RELEASE_CLASS
    due to a bug in Kotlin 1.4.30. (It builds just fine with Gradle)
    t
    • 2
    • 17
  • e

    Endre Deak

    02/12/2021, 12:54 AM
    Hi I’m struggled for hours now to investigate this:
    ./gradlew build
    Configuration on demand is an incubating feature.
    
    > Task :ServerCommon:kaptGenerateStubsKotlin FAILED
    e: org.jetbrains.kotlin.util.ReenteringLazyValueComputationException
    
    
    FAILURE: Build failed with an exception.
    
    * What went wrong:
    Execution failed for task ':ServerCommon:kaptGenerateStubsKotlin'.
    > Internal compiler error. See log for more details
    how can I get into the details? It’s a JVM project, using kotlin and java as well.
    :stackoverflow: 1
    d
    • 2
    • 4
  • m

    Marc Knaup

    02/12/2021, 1:00 PM
    It would be great if we could set up open source libraries and projects for automated unit testing against Kotlin compiler changes. That way any changes are automatically checked against a wide range of code 🙂 It should definitely check incremental builds too as they always cause issues.
    ➕ 1
    r
    d
    • 3
    • 16
  • m

    Marc Knaup

    02/12/2021, 2:08 PM
    Would it be possible to write a compiler plugin that can convert inline XML to Kotlin? Like JSX and TSX.
    val umbrella = <svg xmlns="<http://www.w3.org/2000/svg>" viewBox="0 0 40 40"><path d="M21.172,2.4V0H18.828V2.4C8.063,2.933,0,10.857,0,21.172V23.06l1.694-.839a11.586,11.586,0,0,1,4.243-1.049c1.512,0,3.3,1.445,3.86,2l.829.819.826-.819c.561-.556,2.348-2,3.86-2a6.366,6.366,0,0,1,3.516,1.689V36.484a3.516,3.516,0,0,0,7.031,0V34.141H23.516v2.344a1.172,1.172,0,1,1-2.344,0V22.861a6.366,6.366,0,0,1,3.516-1.689c1.512,0,3.3,1.445,3.86,2l.829.819.826-.819c.561-.556,2.426-2,3.938-2a10.963,10.963,0,0,1,4.165,1.049l1.695.84V21.172C40,10.857,31.937,2.933,21.172,2.4Z"/></svg>
    That could be converted into
    kotlinx-html
    or React code.
    d
    e
    +2
    • 5
    • 27
  • f

    Fudge

    02/23/2021, 8:17 AM
    Is it possible at this point to analyze a kotlin project using the new compiler frontend?
    d
    z
    • 3
    • 4
  • d

    Drew Hamilton

    02/23/2021, 12:56 PM
    What is the significance of an
    IrSimpleFunctionSymbol
    being bound (or not bound)? In particular, if it is being referenced so that it can be called in a generated function, is it meant to be bound to the same
    IrFunction
    that it represents, or to the
    IrFunction
    that is calling it?
    r
    s
    • 3
    • 15
  • y

    Youssef Shoaib [MOD]

    02/25/2021, 9:38 PM
    How do you build a lambda to be passed as a parameter to an inline function? So far, I've tried to use an
    IrFunctionExpressionImpl
    with a function build using
    context.irFactory.buildFun
    but it's giving me issues about the parent. If I try to set the parent to the containing function (i.e. the function that the inline function is called from), it gives me an error saying "unexpected parent functionName". I'm guessing that there's probably something specific that I need to put for the parent but I'm not entirely sure what it is.
    s
    • 2
    • 2
  • l

    Liyue

    03/02/2021, 9:41 AM
    Hi. I trying to get parameter's default value of a function through a
    ValueParameterDescriptor
    , but when the function comes from a class file, it doesn't work.
    fun parseKtCallExpr(callExpr: KtCallExpression, bindingContext:BindingContext){
        val resolvedCall = callExpr.getResolvedCall(bindingContext)
        val defaultParam : ValueParameterDescriptor = resolvedCall.valueArguments[0].key // Suppose it has defaultvalue
        defaultParam.findPsi() as? KtParameter)?.defaultValue  // it works only when function come from code.
    }
    Is there any way to get it? Thanks.
    y
    u
    • 3
    • 3
  • p

    pajatopmr

    03/02/2021, 4:01 PM
    I saw a claim that Kotlin uses nominal (as opposed to structural) type compatibility and equivalence. I have a hunch this is true for JVM but maybe not for Kotlin/Native or Kotlin/JS. Would the claim be correct or is my hunch a good one?
    y
    • 2
    • 6
  • r

    rnett

    03/04/2021, 3:03 AM
    From #multiplatform: https://kotlinlang.slack.com/archives/C3PQML5NU/p1614816886156900
    b
    • 2
    • 4
  • m

    Michal Harakal

    03/05/2021, 4:01 PM
    I trying to run simple plugin from cli. My interpretation of docs is like this
    kotlinc hello.kt -include-runtime -Xplugin=kotlin-ir-plugin-0.1.0-SNAPSHOT.jar -Xuse-ir -d hello.jar
    But I am gettng error
    java.lang.IllegalStateException: The provided plugin com.bnorm.template.TemplateComponentRegistrar is not compatible with this version of compiler
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:592)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$ProjectEnvironment.registerExtensionsFromPlugins(KotlinCoreEnvironment.kt:132)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt:172)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment.<init>(KotlinCoreEnvironment.kt)
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.createForProduction(KotlinCoreEnvironment.kt:426)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.createCoreEnvironment(K2JVMCompiler.kt:226)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:152)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:52)
    	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:88)
    	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.cli.common.CLITool.exec(CLITool.kt:76)
    	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:45)
    	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit(CLITool.kt:227)
    	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMainNoExit$default(CLITool.kt:222)
    	at org.jetbrains.kotlin.cli.common.CLITool$Companion.doMain(CLITool.kt:214)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler$Companion.main(K2JVMCompiler.kt:271)
    	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.main(K2JVMCompiler.kt)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    	at org.jetbrains.kotlin.preloading.Preloader.run(Preloader.java:87)
    	at org.jetbrains.kotlin.preloading.Preloader.main(Preloader.java:44)
    Caused by: java.lang.AbstractMethodError: Receiver class com.bnorm.template.TemplateComponentRegistrar does not define or inherit an implementation of the resolved method 'abstract void registerProjectComponents(com.intellij.mock.MockProject, org.jetbrains.kotlin.config.CompilerConfiguration)' of interface org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar.
    	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment$Companion.registerExtensionsFromPlugins$cli(KotlinCoreEnvironment.kt:584)
    	... 23 more
    Jar file for plugin has been built with gradle from template project by @bnorm https://blog.bnorm.dev/writing-your-second-compiler-plugin-part-1 and units tests are runnign as expected.
    r
    • 2
    • 5
  • b

    Brady Aiello

    03/08/2021, 8:10 PM
    I am trying to implement a compiler plugin by connecting to the FIR instead of IR, the way
    AllOpenVisibilityTransformer
    is a
    DeclarationAttributeAltererExtension
    . But it looks like All Open only works because
    DeclarationAttributeAltererExtension
    is registered in KotlinCoreEnvironment. I'm wondering if there's a way for a user to register a plugin extension point, or if it's gotta go into
    KotlinCoreEnvironment
    , meaning making changes to the compiler itself? For the latter, I'd just want to add a few more methods to
    DeclarationAttributeAltererExtension
    so it could do more than change modality, specifically, changing visibility through a compiler plugin.
    d
    • 2
    • 2
  • p

    PHondogo

    03/09/2021, 8:31 AM
    Hello! Is there any plans to make compiler plugin api public? If yes then when/what version?
    d
    • 2
    • 2
  • a

    Abel

    03/10/2021, 4:45 PM
    Hello, As I explained a few months ago in discuss I'm doing a MsC thesis about optimizations in Kotlin. I have been analyzing the source code of the official Kotlin compiler project. Unfortunately this was more complex than expected, mainly due to its complexity and lack of documentation regarding optimization aspects.  I think I managed to get the general view of how the compiler is structured. I attach the diagram of how I understand it works. Any comment/discussion about it would be really appreciated, either if something is wrong, incomplete, or suggestions to improve it.  Note: even though I don't think it is much different, the code I'm analyzing is the 1.4.20 version/tag. Thank you. [edit: forgot to mention I'm interested in the JVM part]
    👍 1
    🤘🏼 1
    🤘 10
    r
    d
    +5
    • 8
    • 32
  • r

    ralf

    03/15/2021, 1:16 AM
    Are there any resources to read about the new frontend IR? I’m mostly interested in knowing if certain compiler extensions stop working. Does the new frontend still work with Psi?
    👀 2
    d
    r
    r
    • 4
    • 10
  • m

    mbonnin

    03/15/2021, 6:38 PM
    Can I force the compiler to use
    internal
    classes from a library I have no control over? Or is that forever forbidden?
    d
    m
    +2
    • 5
    • 16
  • m

    Michal Harakal

    03/16/2021, 2:02 PM
    @dmitriy.novozhilov AFAIK
    SyntheticResolveExtension
    is executed as a part of analysis phase, in frontend. Which block in your diagram in https://kotlinlang.slack.com/archives/C7L3JB43G/p1615394755006000 is responble for its execution? Do I have the complete PSI with BindingContex?
    d
    • 2
    • 6
  • j

    Jonathan Gerrish

    03/16/2021, 6:00 PM
    Quick question - Is the Kotlin Compiler thread safe? It looks like a shared instance of `K2JVMCompiler`is created in
    KotlinCompileDaemonBase
    ... so I'm assuming so? Background - we are implementing Multiplex worker support for the Bazel Kotlin rules which means a single process will handle multiple concurrent compilation requests so I want to be sure if and how instances should be shared or isolated. Thanks in advance 🙂
    i
    • 2
    • 9
  • y

    Youssef Shoaib [MOD]

    03/21/2021, 5:39 PM
    After digging a bit more it seems like this isn't possible at least JVM-wise because the binaries are distributed as jars instead of as IR like how JS and Native is distributed. Now my question is like can I possibly then access the provided source code of a library (i.e. the .kt file of a specific function like
    let
    from the standard library), compile that as part of the normal code compilation, and then access it's body in IR? I just need a way to inspect inside the code of a function coming in from a different compilation unit in IR instead of having to look into its bytecode. Even if it is a copy of the function and not 100% what the function itself is that's still absolutely fine because I just need to read through it's IR without editing it, and so it's fine with me if I'm taking it's source files and compiling just the ones with the functions that I need to read that IR. So yeah is there any way to get a library's included sources and compile that?
    s
    • 2
    • 10
  • p

    Peter

    03/23/2021, 3:17 PM
    I'm having a compiler error when I try to use property access syntax instead of regular method setter. This is with using the Java XGBoost library.
    val dmat = DMatrix(features, features.size, 1, -1.0f)
    dmat.label(labels) // generates compiler error
    dmat.setLabel(labels) // works fine
    The complier error is: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin Anyone knows what is causing this behavior?
    i
    • 2
    • 2
Powered by Linen
Title
p

Peter

03/23/2021, 3:17 PM
I'm having a compiler error when I try to use property access syntax instead of regular method setter. This is with using the Java XGBoost library.
val dmat = DMatrix(features, features.size, 1, -1.0f)
dmat.label(labels) // generates compiler error
dmat.setLabel(labels) // works fine
The complier error is: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public operator fun <T, R> DeepRecursiveFunction<TypeVariable(T), TypeVariable(R)>.invoke(value: TypeVariable(T)): TypeVariable(R) defined in kotlin Anyone knows what is causing this behavior?
i

Iaroslav Postovalov

03/23/2021, 4:17 PM
Maybe
dmat.label = labels
is correct?
p

Peter

03/23/2021, 8:54 PM
Not sure what I was thinking of, I guess got confused by error. But of course indeed that works. Thanks!!!
View count: 2