;; NOTE: Assertions have been generated by update_lit_checks.py --all-items and should not be edited.

;; RUN: wasm-opt %s --remove-unused-types --closed-world -all -S -o - | filecheck %s

(module
 (rec
  ;; CHECK:      (rec
  ;; CHECK-NEXT:  (type $mutually-used-2 (struct (field (ref null $mutually-used-1))))

  ;; CHECK:       (type $indirectly-used (struct))

  ;; CHECK:       (type $mutually-used-1 (struct (field (ref null $mutually-used-2))))

  ;; CHECK:       (type $directly-used (struct (field (ref null $indirectly-used))))

  ;; CHECK:       (type $used (struct))
  (type $used (struct))
  (type $unused (struct))
 )
 (rec
  (type $indirectly-used (struct))
  (type $directly-used (struct (ref null $indirectly-used)))
  (type $unused2 (struct (ref null $unused2)))
  (type $unused3 (struct (ref null $unused2)))
 )
 (rec
  (type $mutually-used-1 (struct (ref null $mutually-used-2)))
  (type $mutually-used-2 (struct (ref null $mutually-used-1)))
  (type $mutually-unused-1 (struct (ref null $mutually-unused-2)))
  (type $mutually-unused-2 (struct (ref null $mutually-unused-1)))
 )

 ;; CHECK:      (global $g1 (ref null $used) (ref.null none))
 (global $g1 (ref null $used) (ref.null none))
 ;; CHECK:      (global $g2 (ref null $directly-used) (ref.null none))
 (global $g2 (ref null $directly-used) (ref.null none))
 ;; CHECK:      (global $g4 (ref null $mutually-used-1) (ref.null none))
 (global $g4 (ref null $mutually-used-1) (ref.null none))
)
