Fix restriction type inference (fixes #2233)