function Janitor.__index.AddPromise(i,t)if not Promise.is(t)then error(string.format(NOT_A_PROMISE,typeof(t),tostring(t)))end if t:getStatus()==Promise.Status.Started then local o=newproxy(false)local x=i:Add(Promise.resolve(t),"\099\097\110\099\101\108",o)x:finallyCall(i.Remove,i,o)return x else return t end end

function Janitor.__index:AddPromise(PromiseObject)
	if not Promise.is(PromiseObject) then
		error(string.format(NOT_A_PROMISE, typeof(PromiseObject), tostring(PromiseObject)))
	end

	if PromiseObject:getStatus() == Promise.Status.Started then
		local Id = newproxy(false)
		local NewPromise = self:Add(Promise.resolve(PromiseObject), "cancel", Id)
		NewPromise:finallyCall(self.Remove, self, Id)
		return NewPromise
	else
		return PromiseObject
	end
end
