@@ -913,43 +913,15 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
913
913
// of the variant, which is either a tag type in the case of
914
914
// nullary variants or a function type in the case of n-ary
915
915
// variants.
916
+ //
917
+ // TODO: When we have type-parametric tags, this will get a little
918
+ // trickier. Basically, we have to instantiate the variant type we
919
+ // acquire here with the type parameters provided to us by
920
+ // "expected".
916
921
917
- // Grab the values for the type parameters of the tag from the
918
- // expected type.
919
- let vec[ @ty. t] typaram_bindings = vec ( ) ; // FIXME: typestate botch
920
- alt ( expected. struct ) {
921
- case ( ty. ty_tag ( _, ?tps) ) { typaram_bindings = tps; }
922
- case ( _) {
923
- log "tag pattern didn't have tag type?!" ;
924
- fail;
925
- }
926
- }
927
-
928
- // Get the item corresponding to the tag and its type.
929
922
auto vdef = option. get [ ast. variant_def ] ( vdef_opt) ;
930
923
auto variant_ty = fcx. ccx . item_types . get ( vdef. _1 ) ;
931
924
932
- // FIXME: typestate botch
933
- let option. t[ @ast. item] item_opt = none[ @ast. item ] ;
934
- alt ( fcx. ccx . item_items . get ( vdef. _0 ) ) {
935
- case ( any_item_rust ( ?it) ) { item_opt = some[ @ast. item ] ( it) ; }
936
- case ( _) {
937
- log "tag item isn't a Rust item?!" ;
938
- fail;
939
- }
940
- }
941
- let @ast. item item = option. get [ @ast. item ] ( item_opt) ;
942
-
943
- // Get the IDs of the type parameters from that item.
944
- let vec[ ast. ty_param ] ty_params = vec ( ) ; // FIXME: typestate botch
945
- alt ( item. node ) {
946
- case ( ast. item_tag ( _, _, ?tps, _) ) { ty_params = tps; }
947
- case ( _) {
948
- log "tag's corresponding item isn't a tag?!" ;
949
- fail;
950
- }
951
- }
952
-
953
925
auto subpats_len = _vec. len [ @ast. pat ] ( subpats) ;
954
926
alt ( variant_ty. struct ) {
955
927
case ( ty. ty_tag ( _, _) ) {
@@ -958,14 +930,10 @@ fn demand_pat(&@fn_ctxt fcx, @ty.t expected, @ast.pat pat) -> @ast.pat {
958
930
p_1 = ast. pat_tag ( id, subpats, vdef_opt, ast. ann_type ( t) ) ;
959
931
}
960
932
case ( ty. ty_fn ( _, ?args, ?tag_ty) ) {
961
- // N-ary tag variant.
962
933
let vec[ @ast. pat] new_subpats = vec ( ) ;
963
934
auto i = 0 u;
964
935
for ( arg a in args) {
965
- auto arg_ty = ty. substitute_ty_params( ty_params,
966
- typaram_bindings, a. ty) ;
967
- auto new_subpat = demand_pat( fcx, arg_ty,
968
- subpats. ( i) ) ;
936
+ auto new_subpat = demand_pat( fcx, a. ty, subpats. ( i) ) ;
969
937
new_subpats += vec( new_subpat) ;
970
938
i += 1 u;
971
939
}
@@ -1292,13 +1260,14 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
1292
1260
new_subpats += vec ( check_pat ( fcx, subpat) ) ;
1293
1261
}
1294
1262
1295
- auto tag_ty_g = generalize_ty ( fcx. ccx , tag_ty) ;
1296
- auto ann = ast. ann_type ( tag_ty_g) ;
1263
+ auto ann = ast. ann_type ( tag_ty) ;
1297
1264
new_pat = ast. pat_tag ( p, new_subpats, vdef_opt, ann) ;
1298
1265
}
1299
1266
1300
1267
// Nullary variants have tag types.
1301
- case ( ty. ty_tag ( ?tid, ?tps) ) {
1268
+ case ( ty. ty_tag ( ?tid, _) ) {
1269
+ // TODO: ty params
1270
+
1302
1271
auto subpats_len = _vec. len [ @ast. pat ] ( subpats) ;
1303
1272
if ( subpats_len > 0 u) {
1304
1273
// TODO: pluralize properly
@@ -1312,14 +1281,7 @@ fn check_pat(&@fn_ctxt fcx, @ast.pat pat) -> @ast.pat {
1312
1281
fail; // TODO: recover
1313
1282
}
1314
1283
1315
- // Add the appropriate number of type variables.
1316
- let vec[ @ty. t] tys = vec ( ) ;
1317
- auto i = 0 u;
1318
- while ( i < _vec. len [ @ty. t] ( tps) ) {
1319
- tys += vec ( next_ty_var ( fcx. ccx ) ) ;
1320
- i += 1 u;
1321
- }
1322
-
1284
+ let vec[ @ty. t] tys = vec ( ) ; // FIXME
1323
1285
auto ann = ast. ann_type ( plain_ty ( ty. ty_tag ( tid, tys) ) ) ;
1324
1286
new_pat = ast. pat_tag ( p, subpats, vdef_opt, ann) ;
1325
1287
}
0 commit comments