11#![ allow( dead_code) ]
22use crate :: ast_ids:: NodeKey ;
3- use crate :: db:: { QueryResult , SemanticDb } ;
3+ use crate :: db:: { QueryResult , SemanticDb , SemanticJar } ;
44use crate :: files:: FileId ;
55use crate :: symbols:: { symbol_table, GlobalSymbolId , ScopeId , ScopeKind , SymbolId } ;
66use crate :: { FxDashMap , FxIndexSet , Name } ;
@@ -9,7 +9,7 @@ use rustc_hash::FxHashMap;
99
1010pub ( crate ) mod infer;
1111
12- pub ( crate ) use infer:: { infer_definition_type, infer_symbol_type, type_store } ;
12+ pub ( crate ) use infer:: { infer_definition_type, infer_symbol_type} ;
1313
1414/// unique ID for a type
1515#[ derive( Copy , Clone , Debug , PartialEq , Eq , Hash ) ]
@@ -263,8 +263,9 @@ pub struct FunctionTypeId {
263263}
264264
265265impl FunctionTypeId {
266- pub ( crate ) fn function ( self , db : & dyn SemanticDb ) -> QueryResult < FunctionTypeRef > {
267- Ok ( type_store ( db) ?. get_function ( self ) )
266+ fn function ( self , db : & dyn SemanticDb ) -> QueryResult < FunctionTypeRef > {
267+ let jar: & SemanticJar = db. jar ( ) ?;
268+ Ok ( jar. type_store . get_function ( self ) )
268269 }
269270
270271 pub ( crate ) fn name ( self , db : & dyn SemanticDb ) -> QueryResult < Name > {
@@ -283,7 +284,7 @@ impl FunctionTypeId {
283284 }
284285
285286 pub ( crate ) fn symbol ( self , db : & dyn SemanticDb ) -> QueryResult < SymbolId > {
286- let FunctionType { symbol_id, .. } = * type_store ( db) ?. get_function ( self ) ;
287+ let FunctionType { symbol_id, .. } = * self . function ( db) ?;
287288 Ok ( symbol_id)
288289 }
289290
@@ -292,7 +293,7 @@ impl FunctionTypeId {
292293 db : & dyn SemanticDb ,
293294 ) -> QueryResult < Option < ClassTypeId > > {
294295 let table = symbol_table ( db, self . file_id ) ?;
295- let FunctionType { symbol_id, .. } = * type_store ( db) ?. get_function ( self ) ;
296+ let FunctionType { symbol_id, .. } = * self . function ( db) ?;
296297 let scope_id = symbol_id. symbol ( & table) . scope_id ( ) ;
297298 let scope = scope_id. scope ( & table) ;
298299 if !matches ! ( scope. kind( ) , ScopeKind :: Class ) {
@@ -342,9 +343,13 @@ pub struct ClassTypeId {
342343}
343344
344345impl ClassTypeId {
346+ fn class ( self , db : & dyn SemanticDb ) -> QueryResult < ClassTypeRef > {
347+ let jar: & SemanticJar = db. jar ( ) ?;
348+ Ok ( jar. type_store . get_class ( self ) )
349+ }
350+
345351 pub ( crate ) fn name ( self , db : & dyn SemanticDb ) -> QueryResult < Name > {
346- let class = type_store ( db) ?. get_class ( self ) ;
347- Ok ( class. name ( ) . into ( ) )
352+ Ok ( self . class ( db) ?. name ( ) . into ( ) )
348353 }
349354
350355 pub ( crate ) fn get_super_class_member (
@@ -353,7 +358,7 @@ impl ClassTypeId {
353358 name : & Name ,
354359 ) -> QueryResult < Option < Type > > {
355360 // TODO we should linearize the MRO instead of doing this recursively
356- let class = type_store ( db) ?. get_class ( self ) ;
361+ let class = self . class ( db) ?;
357362 for base in class. bases ( ) {
358363 if let Type :: Class ( base) = base {
359364 if let Some ( own_member) = base. get_own_class_member ( db, name) ? {
@@ -369,7 +374,7 @@ impl ClassTypeId {
369374
370375 fn get_own_class_member ( self , db : & dyn SemanticDb , name : & Name ) -> QueryResult < Option < Type > > {
371376 // TODO: this should distinguish instance-only members (e.g. `x: int`) and not return them
372- let ClassType { scope_id, .. } = * type_store ( db) ?. get_class ( self ) ;
377+ let ClassType { scope_id, .. } = * self . class ( db) ?;
373378 let table = symbol_table ( db, self . file_id ) ?;
374379 if let Some ( symbol_id) = table. symbol_id_by_name ( scope_id, name) {
375380 Ok ( Some ( infer_symbol_type (
0 commit comments