Issue #18879: When a method is looked up on a temporary file, avoid closing the file before the method is possibly called.