   }
 }
 
-fileprivate func unwrapFunctionType(_ type: Type) -> Type? {
+fileprivate func simplifyType(_ type: Type) -> Type {
   switch type {
-  case let .attributedType(_, t):
-    return unwrapFunctionType(t)
-  case let .genericType(_, _, t):
-    return unwrapFunctionType(t)
-  case .functionType(_, _):
-    return type
-  default:
-    return nil
-  }
-}
-
-func removeOwnership(_ type: Type) -> Type {
-  switch type {
-  case let .withOwnership(_, subtype): return removeOwnership(subtype)
+  case let .attributedType(_, t): return simplifyType(t)
+  case let .genericType(_, _, t): return simplifyType(t)
+  case let .withOwnership(_, subtype): return simplifyType(subtype)
   default: return type
   }
 }

        updates = [.function(name)]

      case let .partialApply(_, _, fn, _, args, fnType):
        guard case let .functionType(allArgTypes, _) = unwrapFunctionType(fnType) else {
          fatalError("Expected a function type in .partialApply, got: \(fnType)")
        }
        assert(allArgTypes.count >= args.count)

          }
          fallthrough
      case let .apply(_, appliedFnReg, _, appliedArgs, appliedFnType):
        guard case let .functionType(appliedArgTypes, resultType) = simplifyType(appliedFnType) else {
          fatalError("Expected a function type in .apply, got: \(appliedFnType)")
        }
        guard let (name: name, args: bundleArgs, argTypes: bundleArgTypes) = resolveFunction(appliedFnReg) else {
