@@ -850,7 +850,7 @@ impl<'a> Resolver<'a> {
850850 /// Gets or creates a singleton class declaration for a given class/module declaration. For class `Foo`, this
851851 /// returns the declaration for `Foo::<Foo>`.
852852 ///
853- /// If the declaration is a `Constant` with all-promotable definitions, it is automatically promoted to a `Class`
853+ /// If the declaration is a `Constant` with all-promotable definitions, it is automatically promoted to an unknown
854854 /// namespace before creating the singleton. Returns `None` if the declaration is not a namespace and cannot be
855855 /// promoted (e.g., `FOO = 42`).
856856 /// `ancestors` controls how the singleton's ancestor chain is scheduled for linearization —
@@ -874,7 +874,7 @@ impl<'a> Resolver<'a> {
874874 if matches ! ( attached_decl, Declaration :: Constant ( _) ) {
875875 if self . graph . all_definitions_promotable ( attached_decl) {
876876 self . graph . promote_constant_to_namespace ( attached_id, |name, owner_id| {
877- Declaration :: Namespace ( Namespace :: Module ( Box :: new ( ModuleDeclaration :: new ( name, owner_id) ) ) )
877+ Declaration :: Namespace ( Namespace :: Todo ( Box :: new ( TodoDeclaration :: new ( name, owner_id) ) ) )
878878 } ) ;
879879
880880 self . schedule_singleton_ancestors ( attached_id, mode) ;
@@ -1282,16 +1282,16 @@ impl<'a> Resolver<'a> {
12821282 Outcome :: Resolved ( owner_id) => {
12831283 let mut fully_qualified_name = self . graph . strings ( ) . get ( & str_id) . unwrap ( ) . to_string ( ) ;
12841284
1285- // If the owner is a promotable constant and something is being defined inside it, promote it to a
1286- // module
1285+ // If the owner is a promotable constant and something is being defined inside it, promote it to an
1286+ // unknown namespace. A later explicit class or module definition selects the concrete kind.
12871287 {
12881288 let owner = self . graph . declarations ( ) . get ( & owner_id) . unwrap ( ) ;
12891289 let is_promotable_constant =
12901290 matches ! ( owner, Declaration :: Constant ( _) ) && self . graph . all_definitions_promotable ( owner) ;
12911291
12921292 if is_promotable_constant {
12931293 self . graph . promote_constant_to_namespace ( owner_id, |name, owner_id| {
1294- Declaration :: Namespace ( Namespace :: Module ( Box :: new ( ModuleDeclaration :: new ( name, owner_id) ) ) )
1294+ Declaration :: Namespace ( Namespace :: Todo ( Box :: new ( TodoDeclaration :: new ( name, owner_id) ) ) )
12951295 } ) ;
12961296 self . unit_queue . push_back ( Unit :: Ancestors ( owner_id) ) ;
12971297 }
@@ -2028,7 +2028,8 @@ impl<'a> Resolver<'a> {
20282028 let decl = self . graph . declarations ( ) . get ( & attached_id) . unwrap ( ) ;
20292029
20302030 match decl {
2031- Declaration :: Namespace ( Namespace :: Module ( _) ) => ( * MODULE_ID , false ) ,
2031+ // Todo may later become a class or module. Until then, use Module as the singleton-parent fallback.
2032+ Declaration :: Namespace ( Namespace :: Module ( _) | Namespace :: Todo ( _) ) => ( * MODULE_ID , false ) ,
20322033 Declaration :: Namespace ( Namespace :: SingletonClass ( _) ) => {
20332034 // For singleton classes, we keep recursively wrapping parents until we can reach the original attached
20342035 // object
0 commit comments