@@ -2132,15 +2132,20 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2132
2132
}
2133
2133
}
2134
2134
}
2135
- ast:: expr_field ( base, field) {
2135
+ ast:: expr_field ( base, field, tys ) {
2136
2136
bot |= check_expr ( fcx, base) ;
2137
2137
let expr_t = expr_ty ( tcx, base) ;
2138
2138
let base_t = do_autoderef ( fcx, expr. span , expr_t) ;
2139
- let handled = false ;
2139
+ let handled = false , n_tys = vec :: len ( tys ) ;
2140
2140
alt structure_of ( fcx, expr. span , base_t) {
2141
2141
ty:: ty_rec ( fields) {
2142
2142
alt ty:: field_idx ( field, fields) {
2143
2143
some ( ix) {
2144
+ if n_tys > 0 u {
2145
+ tcx. sess . span_err ( expr. span ,
2146
+ "can't provide type parameters \
2147
+ to a field access") ;
2148
+ }
2144
2149
write:: ty_only_fixup ( fcx, id, fields[ ix] . mt . ty ) ;
2145
2150
handled = true ;
2146
2151
}
@@ -2150,6 +2155,11 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2150
2155
ty:: ty_obj ( methods) {
2151
2156
alt ty:: method_idx ( field, methods) {
2152
2157
some ( ix) {
2158
+ if n_tys > 0 u {
2159
+ tcx. sess . span_err ( expr. span ,
2160
+ "can't provide type parameters \
2161
+ to an obj method") ;
2162
+ }
2153
2163
let meth = methods[ ix] ;
2154
2164
let t = ty:: mk_fn ( tcx, meth. proto , meth. inputs ,
2155
2165
meth. output , meth. cf , meth. constrs ) ;
@@ -2181,6 +2191,25 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
2181
2191
fty, method. n_tps ) ;
2182
2192
ids += b. ids ;
2183
2193
fty = b. ty ;
2194
+ if n_tys > 0 u {
2195
+ if n_tys != method. n_tps {
2196
+ tcx. sess . span_fatal
2197
+ ( expr. span , "incorrect number of type \
2198
+ parameters given for this method") ;
2199
+
2200
+ }
2201
+ let i = 0 u;
2202
+ for ty in tys {
2203
+ let tvar = ty:: mk_var ( fcx. ccx . tcx , b. ids [ i] ) ;
2204
+ let t_subst = ast_ty_to_ty_crate ( fcx. ccx , ty) ;
2205
+ demand:: simple ( fcx, expr. span , tvar, t_subst) ;
2206
+ i += 1 u;
2207
+ }
2208
+ }
2209
+ } else if n_tys > 0 u {
2210
+ tcx. sess . span_fatal ( expr. span ,
2211
+ "this method does not take type \
2212
+ parameters") ;
2184
2213
}
2185
2214
let substs = vec:: map ( ids, { |id| ty:: mk_var ( tcx, id) } ) ;
2186
2215
write:: ty_fixup ( fcx, id, { substs : some( substs) , ty: fty} ) ;
0 commit comments