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

turansky

06/22/2022, 12:54 AM
Is it possible to check
is
and
as
expressions? Is there
DeclarationChecker
analog for such checks?
y

Youssef Shoaib [MOD]

06/22/2022, 6:11 AM
If you're asking about FIR there's
ExpressionCheckers
t

turansky

06/22/2022, 7:15 PM
Is FIR used for IR?
d

dmitriy.novozhilov

06/23/2022, 11:48 AM
FIR is not directly related to IR FIR (aka K2) is a new compiler frontend, which works before backend IR stage If you want to report diagnostics on
is
and
as
from compiler plugin then there are two options: 1. Create
DeclarationChecker
in your plugin for old frontend (it's the one with PSI and BindingContext) and manually traverse body with some visitor 2. Write frontend part of your plugin for FIR and create your own
FirTypeOperatorCallChecker
(it will be called only for
is
and
as
expression) First option can be used in production plugin right now (because current frontend is stable) Second option will require to completely rewrite fronted part of your plugin, but it provide more powerful and nice API, so it's great option for some research And if you choose first option you will still require to rewrite your plugin to FIR when it becomes stable and default
2
3 Views