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

;; RUN: foreach %s %t wasm-opt --abstract-type-refining -all --closed-world -S -o - | filecheck %s

;; $uncreated is never created, so we optimize and rebuild types. While doing
;; so we should not get confused as we copy the continuation type, which
;; should end up referring properly to the corresponding func type.

(module
 (rec
  ;; CHECK:      (rec
  ;; CHECK-NEXT:  (type $cont (cont $func))

  ;; CHECK:       (type $func (func))
  (type $func (func))
  (type $cont (cont $func))

  (type $uncreated (struct))
 )

 ;; CHECK:      (elem declare func $func)

 ;; CHECK:      (func $func (type $func)
 ;; CHECK-NEXT: )
 (func $func (type $func)
 )

 ;; CHECK:      (func $test (type $func)
 ;; CHECK-NEXT:  (drop
 ;; CHECK-NEXT:   (cont.new $cont
 ;; CHECK-NEXT:    (ref.func $func)
 ;; CHECK-NEXT:   )
 ;; CHECK-NEXT:  )
 ;; CHECK-NEXT: )
 (func $test (type $func)
  (drop
   (cont.new $cont
    (ref.func $func)
   )
  )
 )
)

