77
88use std:: cell:: RefCell ;
99use std:: cmp:: Ordering ;
10+ use std:: collections:: HashMap ;
1011use std:: fmt;
1112use std:: fmt:: Debug ;
1213use std:: fmt:: Display ;
@@ -55,8 +56,10 @@ use crate::module::module_info::ModuleInfo;
5556use crate :: solver:: solver:: VarRecurser ;
5657use crate :: solver:: type_order:: TypeOrder ;
5758use crate :: types:: class:: Class ;
59+ use crate :: types:: class:: ClassDefIndex ;
5860use crate :: types:: stdlib:: Stdlib ;
5961use crate :: types:: type_info:: TypeInfo ;
62+ use crate :: types:: types:: TParams ;
6063use crate :: types:: types:: Type ;
6164use crate :: types:: types:: Var ;
6265
@@ -378,6 +381,7 @@ pub struct ThreadState {
378381 stack : CalcStack ,
379382 /// For debugging only: thread-global that allows us to control debug logging across components.
380383 debug : RefCell < bool > ,
384+ placeholder_class_tparams : RefCell < HashMap < ClassDefIndex , Arc < TParams > > > ,
381385}
382386
383387impl ThreadState {
@@ -386,6 +390,7 @@ impl ThreadState {
386390 cycles : Cycles :: new ( ) ,
387391 stack : CalcStack :: new ( ) ,
388392 debug : RefCell :: new ( false ) ,
393+ placeholder_class_tparams : RefCell :: new ( HashMap :: new ( ) ) ,
389394 }
390395 }
391396}
@@ -461,6 +466,32 @@ impl<'a, Ans: LookupAnswer> AnswersSolver<'a, Ans> {
461466 & self . thread_state . stack
462467 }
463468
469+ pub fn placeholder_class_tparams ( & self , class_idx : ClassDefIndex ) -> Option < Arc < TParams > > {
470+ self . thread_state
471+ . placeholder_class_tparams
472+ . borrow ( )
473+ . get ( & class_idx)
474+ . cloned ( )
475+ }
476+
477+ pub fn insert_placeholder_class_tparams (
478+ & self ,
479+ class_idx : ClassDefIndex ,
480+ tparams : Arc < TParams > ,
481+ ) {
482+ self . thread_state
483+ . placeholder_class_tparams
484+ . borrow_mut ( )
485+ . insert ( class_idx, tparams) ;
486+ }
487+
488+ pub fn remove_placeholder_class_tparams ( & self , class_idx : ClassDefIndex ) {
489+ self . thread_state
490+ . placeholder_class_tparams
491+ . borrow_mut ( )
492+ . remove ( & class_idx) ;
493+ }
494+
464495 fn cycles ( & self ) -> & Cycles {
465496 & self . thread_state . cycles
466497 }
0 commit comments