1111#![ allow( non_camel_case_types) ]
1212
1313use driver:: session:: Session ;
14+ use lint;
1415use metadata:: csearch;
1516use metadata:: decoder:: { DefLike , DlDef , DlField , DlImpl } ;
1617use middle:: def:: * ;
1718use middle:: lang_items:: LanguageItems ;
1819use middle:: pat_util:: pat_bindings;
1920use middle:: subst:: { ParamSpace , FnSpace , TypeSpace } ;
20- use lint ;
21+ use middle :: ty :: { ExplicitSelfCategory , StaticExplicitSelfCategory } ;
2122use util:: nodemap:: { NodeMap , DefIdSet , FnvHashMap } ;
2223
2324use syntax:: ast:: * ;
@@ -287,6 +288,24 @@ enum ModulePrefixResult {
287288 PrefixFound ( Rc < Module > , uint )
288289}
289290
291+ #[ deriving( Clone , Eq , PartialEq ) ]
292+ enum MethodIsStaticFlag {
293+ MethodIsNotStatic ,
294+ MethodIsStatic ,
295+ }
296+
297+ impl MethodIsStaticFlag {
298+ fn from_explicit_self_category ( explicit_self_category :
299+ ExplicitSelfCategory )
300+ -> MethodIsStaticFlag {
301+ if explicit_self_category == StaticExplicitSelfCategory {
302+ MethodIsStatic
303+ } else {
304+ MethodIsNotStatic
305+ }
306+ }
307+ }
308+
290309#[ deriving( PartialEq ) ]
291310enum NameSearchType {
292311 /// We're doing a name search in order to resolve a `use` directive.
@@ -805,7 +824,8 @@ struct Resolver<'a> {
805824
806825 graph_root : NameBindings ,
807826
808- method_map : RefCell < FnvHashMap < ( Name , DefId ) , ast:: ExplicitSelf_ > > ,
827+ method_map : RefCell < FnvHashMap < ( Name , DefId ) , MethodIsStaticFlag > > ,
828+
809829 structs : FnvHashMap < DefId , Vec < Name > > ,
810830
811831 // The number of imports that are currently unresolved.
@@ -1361,17 +1381,19 @@ impl<'a> Resolver<'a> {
13611381 let ident = ty_m. ident ;
13621382
13631383 // Add it as a name in the trait module.
1364- let def = match ty_m. explicit_self . node {
1384+ let ( def, static_flag ) = match ty_m. explicit_self . node {
13651385 SelfStatic => {
13661386 // Static methods become `def_static_method`s.
1367- DefStaticMethod ( local_def ( ty_m. id ) ,
1387+ ( DefStaticMethod ( local_def ( ty_m. id ) ,
13681388 FromTrait ( local_def ( item. id ) ) ,
1369- ty_m. fn_style )
1389+ ty_m. fn_style ) ,
1390+ MethodIsStatic )
13701391 }
13711392 _ => {
13721393 // Non-static methods become `def_method`s.
1373- DefMethod ( local_def ( ty_m. id ) ,
1374- Some ( local_def ( item. id ) ) )
1394+ ( DefMethod ( local_def ( ty_m. id ) ,
1395+ Some ( local_def ( item. id ) ) ) ,
1396+ MethodIsNotStatic )
13751397 }
13761398 } ;
13771399
@@ -1382,8 +1404,9 @@ impl<'a> Resolver<'a> {
13821404 ty_m. span ) ;
13831405 method_name_bindings. define_value ( def, ty_m. span , true ) ;
13841406
1385- self . method_map . borrow_mut ( ) . insert ( ( ident. name , def_id) ,
1386- ty_m. explicit_self . node ) ;
1407+ self . method_map
1408+ . borrow_mut ( )
1409+ . insert ( ( ident. name , def_id) , static_flag) ;
13871410 }
13881411
13891412 name_bindings. define_type ( DefTrait ( def_id) , sp, is_public) ;
@@ -1670,7 +1693,11 @@ impl<'a> Resolver<'a> {
16701693 trait method '{}'",
16711694 token:: get_ident( method_name) ) ;
16721695
1673- self . method_map . borrow_mut ( ) . insert ( ( method_name. name , def_id) , explicit_self) ;
1696+ self . method_map
1697+ . borrow_mut ( )
1698+ . insert ( ( method_name. name , def_id) ,
1699+ MethodIsStaticFlag :: from_explicit_self_category (
1700+ explicit_self) ) ;
16741701
16751702 if is_exported {
16761703 self . external_exports . insert ( method_def_id) ;
@@ -3678,6 +3705,13 @@ impl<'a> Resolver<'a> {
36783705 this. resolve_type ( & * argument. ty ) ;
36793706 }
36803707
3708+ match ty_m. explicit_self . node {
3709+ SelfExplicit ( ref typ, _) => {
3710+ this. resolve_type ( * typ)
3711+ }
3712+ _ => { }
3713+ }
3714+
36813715 this. resolve_type ( & * ty_m. decl . output ) ;
36823716 } ) ;
36833717 }
@@ -4009,7 +4043,14 @@ impl<'a> Resolver<'a> {
40094043 method. id ,
40104044 rib_kind) ;
40114045
4012- self . resolve_function ( rib_kind, Some ( method. pe_fn_decl ( ) ) , type_parameters,
4046+ match method. pe_explicit_self ( ) . node {
4047+ SelfExplicit ( ref typ, _) => self . resolve_type ( * typ) ,
4048+ _ => { }
4049+ }
4050+
4051+ self . resolve_function ( rib_kind,
4052+ Some ( method. pe_fn_decl ( ) ) ,
4053+ type_parameters,
40134054 method. pe_body ( ) ) ;
40144055 }
40154056
@@ -4765,7 +4806,7 @@ impl<'a> Resolver<'a> {
47654806 match containing_module. def_id . get ( ) {
47664807 Some ( def_id) => {
47674808 match self . method_map . borrow ( ) . find ( & ( ident. name , def_id) ) {
4768- Some ( x ) if * x == SelfStatic => ( ) ,
4809+ Some ( & MethodIsStatic ) => ( ) ,
47694810 None => ( ) ,
47704811 _ => {
47714812 debug ! ( "containing module was a trait or impl \
@@ -5037,7 +5078,7 @@ impl<'a> Resolver<'a> {
50375078 let path_str = self . path_idents_to_string ( & trait_ref. path ) ;
50385079
50395080 match method_map. find ( & ( name, did) ) {
5040- Some ( & SelfStatic ) => return StaticTraitMethod ( path_str) ,
5081+ Some ( & MethodIsStatic ) => return StaticTraitMethod ( path_str) ,
50415082 Some ( _) => return TraitMethod ,
50425083 None => { }
50435084 }
0 commit comments