Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions crates/bsl-types/src/kind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ pub enum MetadataKind {
ExternalDataProcessorObject,
/// `ВнешнийОтчетОбъект.<Имя>`: the ERF counterpart.
ExternalReportObject,
/// `КонстантаМенеджерЗначения.<Имя>`: what `Константы.<Имя>.СоздатьМенеджерЗначения()`
/// returns. Its user methods are the exports of the constant's `ValueManagerModule`,
/// which the module index files in the constant's object slot.
ConstantValueManager,
ExchangePlanRef,
ExchangePlanObject,
ChartOfAccountsRef,
Expand Down Expand Up @@ -264,6 +268,7 @@ impl MetadataKind {
Self::AccumulationRegisterRecord => Some("AccumulationRegisterRecord"),
Self::AccountingRegisterRecord => Some("AccountingRegisterRecord"),
Self::CalculationRegisterRecord => Some("CalculationRegisterRecord"),
Self::ConstantValueManager => Some("ConstantValueManager"),
// The platform corpus keys an external object's members under the bare
// type, not under a dotted `<Kind>.<Name>` prefix: see `bare_platform_type`.
Self::ExternalDataProcessorObject
Expand Down Expand Up @@ -336,6 +341,8 @@ impl MetadataKind {
(Self::ExternalDataProcessorObject, true) => "ExternalDataProcessorObject",
(Self::ExternalReportObject, false) => "ВнешнийОтчётОбъект",
(Self::ExternalReportObject, true) => "ExternalReportObject",
(Self::ConstantValueManager, false) => "КонстантаМенеджерЗначения",
(Self::ConstantValueManager, true) => "ConstantValueManager",
(Self::ExchangePlanRef, false) => "ПланОбменаСсылка",
(Self::ExchangePlanRef, true) => "ExchangePlanRef",
(Self::ExchangePlanObject, false) => "ПланОбменаОбъект",
Expand Down
1 change: 1 addition & 0 deletions crates/hir-ty/src/field_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -747,6 +747,7 @@ pub(crate) fn mdo_type_for_kind(kind: MetadataKind) -> Option<MdoType> {
MetadataKind::ReportObject => Some(MdoType::Report),
MetadataKind::ExternalDataProcessorObject => Some(MdoType::ExternalDataProcessor),
MetadataKind::ExternalReportObject => Some(MdoType::ExternalReport),
MetadataKind::ConstantValueManager => Some(MdoType::Constant),
MetadataKind::ExchangePlanRef | MetadataKind::ExchangePlanObject => {
Some(MdoType::ExchangePlan)
}
Expand Down
16 changes: 1 addition & 15 deletions crates/hir-ty/src/field_lookup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,21 +350,7 @@ fn lookup_field_on_metadata_ref(
}

let TypeKind::MetadataRef(facet) = db.lookup_type(effective_ty) else { return None };
let mdo_type = match facet.kind {
MetadataKind::CatalogObject => MdoType::Catalog,
MetadataKind::DocumentObject => MdoType::Document,
MetadataKind::ExchangePlanObject => MdoType::ExchangePlan,
MetadataKind::ChartOfAccountsObject => MdoType::ChartOfAccounts,
MetadataKind::TaskObject => MdoType::Task,
MetadataKind::BusinessProcessObject => MdoType::BusinessProcess,
MetadataKind::DataProcessorObject => MdoType::DataProcessor,
MetadataKind::ReportObject => MdoType::Report,
MetadataKind::ExternalDataProcessorObject => MdoType::ExternalDataProcessor,
MetadataKind::ExternalReportObject => MdoType::ExternalReport,
MetadataKind::ChartOfCharacteristicTypesObject => MdoType::ChartOfCharacteristicTypes,
MetadataKind::ChartOfCalculationTypesObject => MdoType::ChartOfCalculationTypes,
_ => return None,
};
let mdo_type = crate::method_resolution::object_kind_to_mdo(facet.kind)?;
resolver
.has_effective_module_variable(
ModuleType::ObjectModule,
Expand Down
2 changes: 2 additions & 0 deletions crates/hir-ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4734,6 +4734,8 @@ fn mdo_kind_to_receiver_label(kind: hir_def::ty::MetadataKind) -> Option<&'stati
MetadataKind::ReportObject => bsl_metadata::MdoType::Report,
MetadataKind::ExternalDataProcessorObject => bsl_metadata::MdoType::ExternalDataProcessor,
MetadataKind::ExternalReportObject => bsl_metadata::MdoType::ExternalReport,
// `Константы.<Имя>` is the manager; the value manager is named by its own type.
MetadataKind::ConstantValueManager => return Some("КонстантаМенеджерЗначения"),
MetadataKind::ExchangePlanRef | MetadataKind::ExchangePlanObject => {
bsl_metadata::MdoType::ExchangePlan
}
Expand Down
9 changes: 7 additions & 2 deletions crates/hir-ty/src/method_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ pub fn resolve_qualified_call(
Ok(MethodResolution::new(resolution.method_id, resolution.is_export, signature))
}

fn object_kind_to_mdo(kind: hir_def::ty::MetadataKind) -> Option<bsl_metadata::MdoType> {
/// The object family whose `ObjectModule` slot holds the user module of a value of
/// `kind`: its export methods and export variables are the value's user members.
pub(crate) fn object_kind_to_mdo(kind: hir_def::ty::MetadataKind) -> Option<bsl_metadata::MdoType> {
use bsl_metadata::MdoType;
use hir_def::ty::MetadataKind;
Some(match kind {
Expand All @@ -70,6 +72,8 @@ fn object_kind_to_mdo(kind: hir_def::ty::MetadataKind) -> Option<bsl_metadata::M
MetadataKind::ExternalReportObject => MdoType::ExternalReport,
MetadataKind::ChartOfCharacteristicTypesObject => MdoType::ChartOfCharacteristicTypes,
MetadataKind::ChartOfCalculationTypesObject => MdoType::ChartOfCalculationTypes,
// The module index files a constant's value-manager module in its object slot.
MetadataKind::ConstantValueManager => MdoType::Constant,
MetadataKind::CatalogRef
| MetadataKind::DocumentRef
| MetadataKind::EnumRef
Expand Down Expand Up @@ -121,7 +125,8 @@ fn record_set_kind_to_mdo(kind: hir_def::ty::MetadataKind) -> Option<bsl_metadat
| MetadataKind::ChartOfCalculationTypesObject
| MetadataKind::ReportObject
| MetadataKind::ExternalDataProcessorObject
| MetadataKind::ExternalReportObject => return None,
| MetadataKind::ExternalReportObject
| MetadataKind::ConstantValueManager => return None,
MetadataKind::CatalogRef
| MetadataKind::DocumentRef
| MetadataKind::EnumRef
Expand Down
5 changes: 5 additions & 0 deletions crates/hir-ty/src/platform_manager_lookup/return_mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub(crate) fn metadata_kind_to_prefix_and_mdo(
MetadataKind::CalculationRegisterRecordSet | MetadataKind::CalculationRegisterRecord => {
MdoType::CalculationRegister
}
MetadataKind::ConstantValueManager => MdoType::Constant,
// The external kinds have no prefix; `?` above already answered for them.
MetadataKind::ExternalDataProcessorObject
| MetadataKind::ExternalReportObject
Expand Down Expand Up @@ -163,6 +164,10 @@ pub(crate) fn map_generic_metadata_return_type(
("РегистрРасчетаЗапись" | "CalculationRegisterRecord", MdoType::CalculationRegister) => {
MetadataKind::CalculationRegisterRecord
}
// `Константы.<Имя>.СоздатьМенеджерЗначения()`.
("КонстантаМенеджерЗначения" | "ConstantValueManager", MdoType::Constant) => {
MetadataKind::ConstantValueManager
}
_ => return None,
};
Some(kind)
Expand Down
21 changes: 21 additions & 0 deletions crates/hir-ty/src/subtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ fn is_concrete_to_generic_platform_bridge(from: &TypeKind, to: &TypeKind) -> boo
}
TypeKind::MetadataRef(f) => match f.kind {
MetadataKind::TabularSection { .. } => matches(("ТабличнаяЧасть", "TabularSection")),
MetadataKind::ConstantValueManager => {
matches(("КонстантаМенеджерЗначения", "ConstantValueManager"))
}
kind => object_mdo_of_kind(kind).and_then(generic_object_names).is_some_and(matches),
},
TypeKind::FormControl { kind, .. } => {
Expand Down Expand Up @@ -985,6 +988,24 @@ mod tests {
assert!(is_assignable(&db, this_manager, generic_manager));
}

#[test]
fn constant_value_manager_assignable_to_its_generic_name() {
let db = InMemoryDb::new();
let value_manager = metadata_ref_id(&db, MetadataKind::ConstantValueManager, "СтрокаКонст");
let generic = db.platform_object("КонстантаМенеджерЗначения".to_string());
assert!(is_assignable(&db, value_manager, generic));
assert!(!is_assignable(
&db,
value_manager,
db.platform_object("СправочникОбъект".to_string())
));
assert!(!is_assignable(
&db,
db.platform_object("КонстантаМенеджерЗначения".to_string()),
value_manager
));
}

#[test]
fn tabular_section_assignable_to_generic_tabular_section() {
let db = InMemoryDb::new();
Expand Down
1 change: 1 addition & 0 deletions crates/hir/src/type_facade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ impl<'db, DB: ConfigsDatabase + TypeKernelDb> Type<'db, DB> {
| MetadataKind::AccountingRegisterRecord
| MetadataKind::CalculationRegisterRecordSet
| MetadataKind::CalculationRegisterRecord
| MetadataKind::ConstantValueManager
| MetadataKind::RegisterDimension { .. }
| MetadataKind::RegisterResource { .. }
| MetadataKind::RegisterAttribute { .. }
Expand Down
1 change: 1 addition & 0 deletions crates/ide/src/type_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn mdo_type_of_kind(kind: MetadataKind) -> Option<MdoType> {
MetadataKind::ChartOfCalculationTypesObject => MdoType::ChartOfCalculationTypes,
MetadataKind::DataProcessorObject => MdoType::DataProcessor,
MetadataKind::ReportObject => MdoType::Report,
MetadataKind::ConstantValueManager => MdoType::Constant,
MetadataKind::InformationRegisterRecordSet
| MetadataKind::InformationRegisterRecordManager
| MetadataKind::InformationRegisterRecord => MdoType::InformationRegister,
Expand Down
Loading
Loading