private function replaceInstance($id, $slot, $replace)
    {
        if ($slot){
            if (!$slot->checkTypeRestriction($replace)){
                throw new SlotTypeRestrictionViolationException($id, $replace, $slot->getType());
            }
            if (!$slot->checkInstanceOfRestriction($replace)){
                throw new SlotInstanceOfRestrictionViolationException($id, $replace, $slot->getInstanceOf());
            }
        }
        // replace
        $this->instances[$id] = $replace;
    }