@@ -1440,35 +1440,7 @@ fn eq_raw_ty(&raw_t a, &raw_t b) -> bool {
1440
1440
fn eq_ty ( & t a, & t b) -> bool { ret a == b; }
1441
1441
1442
1442
1443
- fn ann_to_type ( & node_type_table ntt, & ast:: ann ann) -> t {
1444
- alt ( ann) {
1445
- case ( ast:: ann_none ( _) ) {
1446
- log_err "ann_to_type() called on node with no type" ;
1447
- fail;
1448
- }
1449
- case ( ast:: ann_type ( _, ?ty, _, _) ) {
1450
- ret ty;
1451
- }
1452
- }
1453
- }
1454
-
1455
- fn ann_to_type_params ( & node_type_table ntt, & ast:: ann ann) -> vec[ t ] {
1456
- alt ( ann) {
1457
- case ( ast:: ann_none ( _) ) {
1458
- log_err "ann_to_type_params() called on node with no type params" ;
1459
- fail;
1460
- }
1461
- case ( ast:: ann_type ( _, _, ?tps, _) ) {
1462
- alt ( tps) {
1463
- case ( none[ vec[ t] ] ) {
1464
- let vec[ t] result = vec ( ) ;
1465
- ret result;
1466
- }
1467
- case ( some[ vec[ t] ] ( ?tps) ) { ret tps; }
1468
- }
1469
- }
1470
- }
1471
- }
1443
+ // Type lookups
1472
1444
1473
1445
fn ann_to_ty_param_substs_opt_and_ty ( & node_type_table ntt, & ast:: ann ann)
1474
1446
-> ty_param_substs_opt_and_ty {
@@ -1482,27 +1454,33 @@ fn ann_to_ty_param_substs_opt_and_ty(&node_type_table ntt, &ast::ann ann)
1482
1454
}
1483
1455
}
1484
1456
1457
+ fn ann_to_type ( & node_type_table ntt, & ast:: ann ann) -> t {
1458
+ ret ann_to_ty_param_substs_opt_and_ty ( ntt, ann) . _1 ;
1459
+ }
1460
+
1461
+ fn ann_to_type_params ( & node_type_table ntt, & ast:: ann ann) -> vec[ t ] {
1462
+ alt ( ann_to_ty_param_substs_opt_and_ty ( ntt, ann) . _0 ) {
1463
+ case ( none[ vec[ t] ] ) {
1464
+ let vec[ t] result = vec ( ) ;
1465
+ ret result;
1466
+ }
1467
+ case ( some[ vec[ t] ] ( ?tps) ) { ret tps; }
1468
+ }
1469
+ }
1470
+
1485
1471
// Returns the type of an annotation, with type parameter substitutions
1486
1472
// performed if applicable.
1487
- fn ann_to_monotype ( ctxt cx, & node_type_table ntt, ast:: ann a) -> t {
1488
- // TODO: Refactor to use recursive pattern matching when we're more
1489
- // confident that it works.
1490
- alt ( a) {
1491
- case ( ast:: ann_none ( _) ) {
1492
- log_err "ann_to_monotype() called on expression with no type!" ;
1493
- fail;
1494
- }
1495
- case ( ast:: ann_type ( _, ?typ, ?tps_opt, _) ) {
1496
- alt ( tps_opt) {
1497
- case ( none[ vec[ t] ] ) { ret typ; }
1498
- case ( some[ vec[ t] ] ( ?tps) ) {
1499
- ret substitute_type_params ( cx, tps, typ) ;
1500
- }
1501
- }
1473
+ fn ann_to_monotype ( ctxt cx, & node_type_table ntt, ast:: ann a) -> t {
1474
+ auto tpot = ann_to_ty_param_substs_opt_and_ty ( ntt, a) ;
1475
+ alt ( tpot. _0 ) {
1476
+ case ( none[ vec[ t] ] ) { ret tpot. _1 ; }
1477
+ case ( some[ vec[ t] ] ( ?tps) ) {
1478
+ ret substitute_type_params ( cx, tps, tpot. _1 ) ;
1502
1479
}
1503
1480
}
1504
1481
}
1505
1482
1483
+
1506
1484
// Turns a type into an ann_type, using defaults for other fields.
1507
1485
fn triv_ann ( uint node_id , t typ ) -> ast:: ann {
1508
1486
ret ast:: ann_type ( node_id, typ, none[ vec[ t] ] , none[ @ts_ann] ) ;
0 commit comments