I wrote a back-end of my plugin that generates som...
# compiler
g
I wrote a back-end of my plugin that generates some new IR elements including declarations (properties mostly). (For now, there is no front-end in that plugin.) For some reason, the declarations are invisible from dependent modules. What do I have to do to mark them visible for dependent modules?
For example, the following test passes.
Copy code
// SUPPRESS_WARNINGS: PRE_RELEASE_CLASS

import dev.lounres.kone.suppliedTypes.*


interface Foo<@Supplied T>

interface Bar<@Supplied U> : Foo<Map<out U, *>>
while the following test does not.
Copy code
// SUPPRESS_WARNINGS: PRE_RELEASE_CLASS

// MODULE: foo
import dev.lounres.kone.suppliedTypes.*


interface Foo<@Supplied T>

// MODULE: bar(foo)
import dev.lounres.kone.suppliedTypes.*


interface Bar<@Supplied U> : Foo<Map<out U, *>>
j
are invisible on the IDE, or in general?
g
In general. Both compilation of real sources and the test fail.
p
Ideally, if it's expected to be public declarations, you should generate them in FIR part of plugin, and then create bodies in IR. This would also make it working within module (which is more consistent, than when it works only in diffrent modules) and would enable you to make them IDE visible by IDE plugin. If you really want them to be visible only from other modules, you can use
registerFunctionAsMetadataVisible
and similar methods from
metadataDeclarationRegistrar
. Note, that they are very limited in usages (e.g. don't work for top-levels).
g
Well, I would like them to be visible only for compiler. I mean that I generate a property and its overloads for each type parameter marked with
@Supplied
, which should not be accessible for user directly (instead, one can call
suppliedTypeOf<...>()
to get a value constructed using the value of the property). I'll look into
metadataDeclarationRegistrar
at first. Thank you!
p
What do you mean as visible for other modules then? Because this would make it visibile for users in other modules. Potentially use can create it as
@Deprecated(level=HIDDEN)
, than compiler would see it, but users wouldn't.
g
In the second example above during modification of
Bar
interface IR I tried to dump the
Foo
interface IR. The dump (with origin
IR_EXTERNAL_DECLARATION_STUB
) does not contain the property I created when I modified the Foo interface IR. But I would like to override the property in
Bar
during compilation of the
bar
module. It means that compiler have to be able to see the generated property when it compiles dependent module. But I would like to hide the property from user.