cast() method in DiagnosticFactory