|
18 | 18 | ;; CHECK: (table $table 93 funcref) |
19 | 19 | (table $table 93 funcref) |
20 | 20 |
|
21 | | - ;; CHECK: (elem $elem (i32.const 0) $sub) |
22 | | - (elem $elem (i32.const 0) $sub) |
| 21 | + ;; CHECK: (elem $elem (i32.const 0) $target) |
| 22 | + (elem $elem (i32.const 0) $target) |
23 | 23 |
|
24 | 24 | ;; CHECK: (export "caller" (func $caller)) |
25 | 25 |
|
26 | 26 | ;; CHECK: (func $caller (type $0) |
27 | | - ;; CHECK-NEXT: (call $sub) |
| 27 | + ;; CHECK-NEXT: (call $target) |
28 | 28 | ;; CHECK-NEXT: ) |
29 | 29 | (func $caller (export "caller") |
30 | 30 | ;; This turns into a direct call. |
|
33 | 33 | ) |
34 | 34 | ) |
35 | 35 |
|
36 | | - ;; CHECK: (func $sub (type $sub) |
| 36 | + ;; CHECK: (func $target (type $sub) |
37 | 37 | ;; CHECK-NEXT: ) |
38 | | - (func $sub (type $sub) |
| 38 | + (func $target (type $sub) |
39 | 39 | ) |
40 | 40 | ) |
41 | 41 |
|
|
47 | 47 | ;; CHECK: (rec |
48 | 48 | ;; CHECK-NEXT: (type $super (sub (func))) |
49 | 49 | (type $super (sub (func))) |
50 | | - ;; CHECK: (type $sub (sub (func))) |
51 | | - (type $sub (sub (func))) |
| 50 | + ;; CHECK: (type $other (sub (func))) |
| 51 | + (type $other (sub (func))) |
52 | 52 | ) |
53 | 53 |
|
54 | 54 | ;; CHECK: (table $table 93 funcref) |
55 | 55 | (table $table 93 funcref) |
56 | 56 |
|
57 | | - ;; CHECK: (elem $elem (i32.const 0) $sub) |
58 | | - (elem $elem (i32.const 0) $sub) |
| 57 | + ;; CHECK: (elem $elem (i32.const 0) $target) |
| 58 | + (elem $elem (i32.const 0) $target) |
59 | 59 |
|
60 | 60 | ;; CHECK: (export "caller" (func $caller)) |
61 | 61 |
|
|
69 | 69 | ) |
70 | 70 | ) |
71 | 71 |
|
72 | | - ;; CHECK: (func $sub (type $sub) |
| 72 | + ;; CHECK: (func $target (type $other) |
73 | 73 | ;; CHECK-NEXT: ) |
74 | | - (func $sub (type $sub) |
| 74 | + (func $target (type $other) |
| 75 | + ) |
| 76 | +) |
| 77 | + |
| 78 | +;; Reverse the subtyping: Call a supertype with a subtype. This call should |
| 79 | +;; fail. |
| 80 | +(module |
| 81 | + (rec |
| 82 | + ;; CHECK: (type $0 (func)) |
| 83 | + |
| 84 | + ;; CHECK: (rec |
| 85 | + ;; CHECK-NEXT: (type $super (sub (func))) |
| 86 | + (type $super (sub (func))) |
| 87 | + ;; CHECK: (type $sub (sub final $super (func))) |
| 88 | + (type $sub (sub final $super (func))) |
| 89 | + ) |
| 90 | + |
| 91 | + ;; CHECK: (table $table 93 funcref) |
| 92 | + (table $table 93 funcref) |
| 93 | + |
| 94 | + ;; CHECK: (elem $elem (i32.const 0) $target) |
| 95 | + (elem $elem (i32.const 0) $target) |
| 96 | + |
| 97 | + ;; CHECK: (export "caller" (func $caller)) |
| 98 | + |
| 99 | + ;; CHECK: (func $caller (type $0) |
| 100 | + ;; CHECK-NEXT: (unreachable) |
| 101 | + ;; CHECK-NEXT: ) |
| 102 | + (func $caller (export "caller") |
| 103 | + ;; This turns into a direct call. |
| 104 | + (call_indirect (type $sub) |
| 105 | + (i32.const 0) |
| 106 | + ) |
| 107 | + ) |
| 108 | + |
| 109 | + ;; CHECK: (func $target (type $super) |
| 110 | + ;; CHECK-NEXT: ) |
| 111 | + (func $target (type $super) |
75 | 112 | ) |
76 | 113 | ) |
77 | 114 |
|
0 commit comments