import UserApp's provided types into the Package-Config module

This commit is contained in:
Folkert 2022-01-23 18:33:50 +01:00
parent 4fadc775e8
commit 6545968c34
2 changed files with 17 additions and 0 deletions

View file

@ -177,6 +177,7 @@ impl<'a> RemoveSpaces<'a> for Module<'a> {
packages: header.packages.remove_spaces(arena), packages: header.packages.remove_spaces(arena),
imports: header.imports.remove_spaces(arena), imports: header.imports.remove_spaces(arena),
provides: header.provides.remove_spaces(arena), provides: header.provides.remove_spaces(arena),
provides_types: header.provides_types.map(|ts| ts.remove_spaces(arena)),
to: header.to.remove_spaces(arena), to: header.to.remove_spaces(arena),
before_header: &[], before_header: &[],
after_app_keyword: &[], after_app_keyword: &[],

View file

@ -26,6 +26,7 @@ use roc_mono::layout::{Layout, LayoutCache, LayoutProblem};
use roc_parse::ast::{self, ExtractSpaces, Spaced, StrLiteral, TypeAnnotation}; use roc_parse::ast::{self, ExtractSpaces, Spaced, StrLiteral, TypeAnnotation};
use roc_parse::header::PackageName; use roc_parse::header::PackageName;
use roc_parse::header::{ExposedName, ImportsEntry, PackageEntry, PlatformHeader, To, TypedIdent}; use roc_parse::header::{ExposedName, ImportsEntry, PackageEntry, PlatformHeader, To, TypedIdent};
use roc_parse::ident::UppercaseIdent;
use roc_parse::module::module_defs; use roc_parse::module::module_defs;
use roc_parse::parser::{FileError, Parser, SyntaxError}; use roc_parse::parser::{FileError, Parser, SyntaxError};
use roc_region::all::{LineInfo, Loc, Region}; use roc_region::all::{LineInfo, Loc, Region};
@ -2920,6 +2921,7 @@ struct PlatformHeaderInfo<'a> {
packages: &'a [Loc<PackageEntry<'a>>], packages: &'a [Loc<PackageEntry<'a>>],
provides: &'a [Loc<ExposedName<'a>>], provides: &'a [Loc<ExposedName<'a>>],
requires: &'a [Loc<TypedIdent<'a>>], requires: &'a [Loc<TypedIdent<'a>>],
requires_types: &'a [Loc<UppercaseIdent<'a>>],
imports: &'a [Loc<ImportsEntry<'a>>], imports: &'a [Loc<ImportsEntry<'a>>],
} }
@ -2940,6 +2942,7 @@ fn send_header_two<'a>(
packages, packages,
provides, provides,
requires, requires,
requires_types,
imports, imports,
} = info; } = info;
@ -3044,6 +3047,18 @@ fn send_header_two<'a>(
scope.insert(ident, (symbol, entry.ident.region)); scope.insert(ident, (symbol, entry.ident.region));
} }
for entry in requires_types {
let string: &str = entry.value.into();
let ident: Ident = string.into();
let ident_id = ident_ids.get_or_insert(&ident);
let symbol = Symbol::new(app_module_id, ident_id);
// Since this value is exposed, add it to our module's default scope.
debug_assert!(!scope.contains_key(&ident.clone()));
scope.insert(ident, (symbol, entry.region));
}
} }
let ident_ids = ident_ids_by_module.get_mut(&home).unwrap(); let ident_ids = ident_ids_by_module.get_mut(&home).unwrap();
@ -3289,6 +3304,7 @@ fn fabricate_pkg_config_module<'a>(
header.requires.signature.region, header.requires.signature.region,
header.requires.signature.extract_spaces().item, header.requires.signature.extract_spaces().item,
)]), )]),
requires_types: unspace(arena, header.requires.rigids.items),
imports: unspace(arena, header.imports.items), imports: unspace(arena, header.imports.items),
}; };