;; NOTE: Assertions have been generated by update_lit_checks.py and should not be edited. ;; RUN: wasm-opt %s --local-subtyping -all -S -o - | filecheck %s (module (type $struct (struct)) ;; CHECK: (import "out" "i32" (func $i32 (type $0) (result i32))) (import "out" "i32" (func $i32 (result i32))) ;; CHECK: (func $non-nullable (type $1) ;; CHECK-NEXT: (local $x (ref none)) ;; CHECK-NEXT: (local $y (ref $0)) ;; CHECK-NEXT: (local.set $x ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (local.set $y ;; CHECK-NEXT: (ref.func $i32) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $non-nullable (local $x (ref null $struct)) (local $y funcref) ;; x is assigned a value that is non-nullable. (local.set $x (ref.as_non_null (ref.null $struct)) ) ;; y is assigned a value that is non-nullable, and also allows a more ;; specific heap type. (local.set $y (ref.func $i32) ) ;; Verify that the presence of a get does not alter things. (drop (local.get $x) ) ) ;; CHECK: (func $uses-default (type $2) (param $i i32) ;; CHECK-NEXT: (local $x nullref) ;; CHECK-NEXT: (if ;; CHECK-NEXT: (local.get $i) ;; CHECK-NEXT: (then ;; CHECK-NEXT: (local.set $x ;; CHECK-NEXT: (ref.as_non_null ;; CHECK-NEXT: (ref.null none) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) ;; CHECK-NEXT: (drop ;; CHECK-NEXT: (local.get $x) ;; CHECK-NEXT: ) ;; CHECK-NEXT: ) (func $uses-default (param $i i32) (local $x (ref null any)) (if (local.get $i) ;; The only set to this local uses a non-nullable type. (then (local.set $x (ref.as_non_null (ref.null $struct)) ) ) ) (drop ;; This get may use the null value, so we can refine the heap type but not ;; alter nullability. (local.get $x) ) ) )