Move extend identifier check in the closure

Move the check of the identifier to extend in the closure to allowed to extends a service is not defined yet.