@@ -192,7 +192,7 @@ impl<'self> LookupContext<'self> {
192
192
193
193
// Prepare the list of candidates
194
194
self . push_inherent_candidates ( self_ty) ;
195
- self . push_extension_candidates ( ) ;
195
+ self . push_extension_candidates ( self_ty ) ;
196
196
197
197
let mut enum_dids = ~[ ] ;
198
198
let mut self_ty = self_ty;
@@ -295,7 +295,7 @@ impl<'self> LookupContext<'self> {
295
295
ty_trait( did, ref substs, store, _, _) => {
296
296
self . push_inherent_candidates_from_trait (
297
297
self_ty, did, substs, store) ;
298
- self . push_inherent_impl_candidates_for_type ( did) ;
298
+ self . push_inherent_impl_candidates_for_type ( self_ty , did) ;
299
299
}
300
300
ty_self( self_did) => {
301
301
// Call is of the form "self.foo()" and appears in one
@@ -310,7 +310,8 @@ impl<'self> LookupContext<'self> {
310
310
}
311
311
ty_enum( did, _) | ty_struct( did, _) => {
312
312
if self . check_traits == CheckTraitsAndInherentMethods {
313
- self . push_inherent_impl_candidates_for_type ( did) ;
313
+ self . push_inherent_impl_candidates_for_type ( self_ty,
314
+ did) ;
314
315
}
315
316
}
316
317
_ => { /* No inherent methods in these types */ }
@@ -326,7 +327,7 @@ impl<'self> LookupContext<'self> {
326
327
}
327
328
}
328
329
329
- pub fn push_extension_candidates ( & self ) {
330
+ pub fn push_extension_candidates ( & self , self_ty : ty :: t ) {
330
331
// If the method being called is associated with a trait, then
331
332
// find all the impls of that trait. Each of those are
332
333
// candidates.
@@ -342,7 +343,7 @@ impl<'self> LookupContext<'self> {
342
343
for opt_impl_infos. iter( ) . advance |impl_infos| {
343
344
for impl_infos. iter( ) . advance |impl_info| {
344
345
self . push_candidates_from_impl(
345
- self . extension_candidates, * impl_info) ;
346
+ self_ty , self . extension_candidates, * impl_info) ;
346
347
347
348
}
348
349
}
@@ -523,18 +524,21 @@ impl<'self> LookupContext<'self> {
523
524
}
524
525
}
525
526
526
- pub fn push_inherent_impl_candidates_for_type( & self , did: def_id) {
527
+ pub fn push_inherent_impl_candidates_for_type( & self ,
528
+ self_ty: ty:: t,
529
+ did: def_id) {
527
530
let opt_impl_infos =
528
531
self . fcx. ccx. coherence_info. inherent_methods. find( & did) ;
529
532
for opt_impl_infos. iter( ) . advance |impl_infos| {
530
533
for impl_infos. iter( ) . advance |impl_info| {
531
534
self . push_candidates_from_impl(
532
- self . inherent_candidates, * impl_info) ;
535
+ self_ty , self . inherent_candidates, * impl_info) ;
533
536
}
534
537
}
535
538
}
536
539
537
540
pub fn push_candidates_from_impl( & self ,
541
+ self_ty: ty:: t,
538
542
candidates: & mut ~[ Candidate ] ,
539
543
impl_info: & resolve:: Impl ) {
540
544
if !self . impl_dups. insert( impl_info. did) {
@@ -561,17 +565,25 @@ impl<'self> LookupContext<'self> {
561
565
ccx : self . fcx. ccx,
562
566
infcx : self . fcx. infcx( )
563
567
} ;
564
- let ty:: ty_param_substs_and_ty {
565
- substs : impl_substs,
566
- ty : impl_ty
567
- } = impl_self_ty( & vcx, location_info, impl_info. did) ;
568
-
569
- candidates. push( Candidate {
570
- rcvr_ty : impl_ty,
571
- rcvr_substs : impl_substs,
572
- method_ty : method,
573
- origin : method_static( method. def_id)
574
- } ) ;
568
+ match impl_self_ty( & vcx, location_info, impl_info. did, Some ( self_ty) ) {
569
+ Some ( ty:: ty_param_substs_and_ty {
570
+ substs : impl_substs,
571
+ ty : impl_ty
572
+ } ) => {
573
+ candidates. push( Candidate {
574
+ rcvr_ty : impl_ty,
575
+ rcvr_substs : impl_substs,
576
+ method_ty : method,
577
+ origin : method_static( method. def_id)
578
+ } ) ;
579
+ } ,
580
+ None => {
581
+ debug ! ( "push_candidates_from_impl match failed: %s %s %s" ,
582
+ self . m_name. repr( self . tcx( ) ) ,
583
+ impl_info. ident. repr( self . tcx( ) ) ,
584
+ impl_info. methods. map( |m| m. ident) . repr( self . tcx( ) ) ) ;
585
+ }
586
+ }
575
587
}
576
588
577
589
// ______________________________________________________________________
0 commit comments