@@ -1782,7 +1782,7 @@ fn lookup_method(fcx: @fn_ctxt, expr: @ast::expr, node_id: ast::node_id,
1782
1782
some ( { method_ty: fty, n_tps: method_n_tps, substs, origin, self_sub} ) {
1783
1783
let tcx = fcx. ccx . tcx ;
1784
1784
let substs = substs, n_tps = vec:: len ( substs) , n_tys = vec:: len ( tps) ;
1785
- let has_self = ty:: type_has_params ( fty) ;
1785
+ let has_self = ty:: type_has_vars ( fty) ;
1786
1786
if method_n_tps + n_tps > 0 u {
1787
1787
if n_tys == 0 u || n_tys != method_n_tps {
1788
1788
if n_tys != 0 u {
@@ -3335,15 +3335,16 @@ mod vtable {
3335
3335
}
3336
3336
3337
3337
fn lookup_vtables( fcx : @fn_ctxt , isc : resolve:: iscopes , sp : span ,
3338
- bounds : @[ ty:: param_bounds ] , tys : [ ty:: t ] )
3339
- -> vtable_res {
3338
+ bounds : @[ ty:: param_bounds ] , tys : [ ty:: t ] ,
3339
+ allow_unsafe : bool ) -> vtable_res {
3340
3340
let tcx = fcx. ccx . tcx , result = [ ] , i = 0 u;
3341
3341
for ty in tys {
3342
3342
for bound in * bounds[ i] {
3343
3343
alt bound {
3344
3344
ty : : bound_iface ( i_ty) {
3345
3345
let i_ty = ty:: substitute_type_params ( tcx, tys, i_ty) ;
3346
- result += [ lookup_vtable ( fcx, isc, sp, ty, i_ty) ] ;
3346
+ result += [ lookup_vtable ( fcx, isc, sp, ty, i_ty,
3347
+ allow_unsafe) ] ;
3347
3348
}
3348
3349
_ { }
3349
3350
}
@@ -3354,7 +3355,8 @@ mod vtable {
3354
3355
}
3355
3356
3356
3357
fn lookup_vtable( fcx : @fn_ctxt , isc : resolve:: iscopes , sp : span ,
3357
- ty : ty:: t , iface_ty : ty:: t ) -> vtable_origin {
3358
+ ty : ty:: t , iface_ty : ty:: t , allow_unsafe : bool )
3359
+ -> vtable_origin {
3358
3360
let tcx = fcx. ccx . tcx ;
3359
3361
let ( iface_id, iface_tps) = alt check ty:: get ( iface_ty) . struct {
3360
3362
ty:: ty_iface ( did, tps) { ( did, tps) }
@@ -3378,6 +3380,20 @@ mod vtable {
3378
3380
}
3379
3381
}
3380
3382
ty:: ty_iface ( did, tps) if iface_id == did {
3383
+ if !allow_unsafe {
3384
+ for m in * ty:: iface_methods ( tcx, did) {
3385
+ if ty:: type_has_vars ( ty:: mk_fn ( tcx, m. fty ) ) {
3386
+ tcx. sess . span_err (
3387
+ sp, "a boxed iface with self types may not be \
3388
+ passed as a bounded type") ;
3389
+ } else if ( * m. tps ) . len ( ) > 0 u {
3390
+ tcx. sess . span_err (
3391
+ sp, "a boxed iface with generic methods may not \
3392
+ be passed as a bounded type") ;
3393
+
3394
+ }
3395
+ }
3396
+ }
3381
3397
ret vtable_iface ( did, tps) ;
3382
3398
}
3383
3399
_ {
@@ -3410,8 +3426,8 @@ mod vtable {
3410
3426
im. did ) ;
3411
3427
let params = vec:: map ( vars, { |t|
3412
3428
fixup_ty ( fcx, sp, t) } ) ;
3413
- let subres = lookup_vtables ( fcx , isc , sp ,
3414
- im_bs, params) ;
3429
+ let subres = lookup_vtables (
3430
+ fcx , isc , sp , im_bs, params, false ) ;
3415
3431
found = some ( vtable_static ( im. did , params,
3416
3432
subres) ) ;
3417
3433
}
@@ -3469,7 +3485,7 @@ mod vtable {
3469
3485
if has_iface_bounds ( * item_ty. bounds ) {
3470
3486
let impls = cx. impl_map . get ( ex. id ) ;
3471
3487
cx. vtable_map . insert ( ex. id , lookup_vtables (
3472
- fcx, impls, ex. span , item_ty. bounds , ts) ) ;
3488
+ fcx, impls, ex. span , item_ty. bounds , ts, false ) ) ;
3473
3489
}
3474
3490
}
3475
3491
_ { }
@@ -3490,7 +3506,7 @@ mod vtable {
3490
3506
let ts = ty:: node_id_to_type_params ( cx. tcx , callee_id) ;
3491
3507
let iscs = cx. impl_map . get ( ex. id ) ;
3492
3508
cx. vtable_map . insert ( callee_id, lookup_vtables (
3493
- fcx, iscs, ex. span , bounds, ts) ) ;
3509
+ fcx, iscs, ex. span , bounds, ts, false ) ) ;
3494
3510
}
3495
3511
}
3496
3512
_ { }
@@ -3502,7 +3518,8 @@ mod vtable {
3502
3518
ty:: ty_iface ( _, _) {
3503
3519
let impls = cx. impl_map . get ( ex. id ) ;
3504
3520
let vtable = lookup_vtable ( fcx, impls, ex. span ,
3505
- expr_ty ( cx. tcx , src) , target_ty) ;
3521
+ expr_ty ( cx. tcx , src) , target_ty,
3522
+ true ) ;
3506
3523
cx. vtable_map . insert ( ex. id , @[ vtable] ) ;
3507
3524
}
3508
3525
_ { }
0 commit comments