https://kotlinlang.org logo
#compiler
Title
# compiler
r

rnett

09/23/2020, 4:17 AM
Another possible JS related bug: I'm trying to extract the value of a top level constant property (i.e.
const val prop = "..."
). I'm using
context.referenceProperties(name).single().owner.backingField!!.initalizer!!.expression as IrConst<String>
and it works fine on JVM, however on JS
backingField.expression
is
IrErrorExpressionImpl: Expression body is not deserialized yet
. I'll make an issue if this is indeed a bug, but wanted to check its not due to me miss-using something (should I just make an issue in the future?).
r

Roman Artemev [JB]

09/25/2020, 9:58 AM
Hi, actually field initializer is considered to be private module data and shouldn’t be accessible.
r

rnett

09/25/2020, 6:50 PM
Are there plans for a way to access const properties' values then? It seems like something that should be accessible.
r

Roman Artemev [JB]

09/26/2020, 9:24 AM
I think yes at least constant properties seems like they could be accessible. But I definitely cannot promise that for general property.
BTW could you please create an YT issue about constant properties
When you say "field initializer is considered to be private module data", you mean that we won't be able to access initializers in already compiled code/other modules? I assume we will still be able to access field initializers for the code we are transforming?
r

Roman Artemev [JB]

09/28/2020, 12:23 PM
Let me make it a bit clear. You have a full access to any currently compiling module data including any private/local declaration, initializer and so on. If we are talking about dependency in that case you have access only to its API “surface” which includes publicly accessible declarations and some exceptions (one of them going to be constant initializer)
👍 1
2 Views