Skip to content

Commit d154964

Browse files
committed
test the reverse
1 parent 7b23f0a commit d154964

1 file changed

Lines changed: 48 additions & 11 deletions

File tree

test/lit/passes/directize-gc.wast

Lines changed: 48 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
;; CHECK: (table $table 93 funcref)
1919
(table $table 93 funcref)
2020

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)
2323

2424
;; CHECK: (export "caller" (func $caller))
2525

2626
;; CHECK: (func $caller (type $0)
27-
;; CHECK-NEXT: (call $sub)
27+
;; CHECK-NEXT: (call $target)
2828
;; CHECK-NEXT: )
2929
(func $caller (export "caller")
3030
;; This turns into a direct call.
@@ -33,9 +33,9 @@
3333
)
3434
)
3535

36-
;; CHECK: (func $sub (type $sub)
36+
;; CHECK: (func $target (type $sub)
3737
;; CHECK-NEXT: )
38-
(func $sub (type $sub)
38+
(func $target (type $sub)
3939
)
4040
)
4141

@@ -47,15 +47,15 @@
4747
;; CHECK: (rec
4848
;; CHECK-NEXT: (type $super (sub (func)))
4949
(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)))
5252
)
5353

5454
;; CHECK: (table $table 93 funcref)
5555
(table $table 93 funcref)
5656

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)
5959

6060
;; CHECK: (export "caller" (func $caller))
6161

@@ -69,9 +69,46 @@
6969
)
7070
)
7171

72-
;; CHECK: (func $sub (type $sub)
72+
;; CHECK: (func $target (type $other)
7373
;; 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)
75112
)
76113
)
77114

0 commit comments

Comments
 (0)