function Promise.prototype._finalize(M)for B,S in ipairs(M._queuedFinally)do(coroutine.wrap(S))(M._status)end M._queuedFinally=nil M._queuedReject=nil M._queuedResolve=nil if not Promise.TEST then M._parent=nil M._consumers=nil end end

function Promise.prototype:_finalize()
	for _, callback in ipairs(self._queuedFinally) do
		-- Purposefully not passing values to callbacks here, as it could be the
		-- resolved values, or rejected errors. If the developer needs the values,
		-- they should use :andThen or :catch explicitly.
		coroutine.wrap(callback)(self._status)
	end

	self._queuedFinally = nil
	self._queuedReject = nil
	self._queuedResolve = nil

	-- Clear references to other Promises to allow gc
	if not Promise.TEST then
		self._parent = nil
		self._consumers = nil
	end
end
