Skip to main content

kotlin_codegen/
slot.rs

1//! Expression value positions in the declaration model.
2
3use super::code::KtCode;
4
5/// A property's value: no value, an initializer, or a delegate.
6///
7/// Replaces the old two-`Option<String>` fields — a sum, so the illegal
8/// state (both set at once) is unrepresentable.
9#[derive(Clone, Debug, Default)]
10pub enum KtPropertyValue {
11    /// No value — an abstract property, or one with only accessors.
12    #[default]
13    None,
14    /// `val x = <expr>`.
15    Initializer(KtCode),
16    /// `val x by <expr>` (e.g. `lazy { … }`).
17    Delegate(KtCode),
18}
19
20impl KtPropertyValue {
21    pub fn collect_imports(&self, sink: &mut Vec<String>) {
22        match self {
23            KtPropertyValue::None => {}
24            KtPropertyValue::Initializer(c) | KtPropertyValue::Delegate(c) => {
25                c.collect_imports(sink)
26            }
27        }
28    }
29}