From 5b3767003a8e49a79a33180c9c77f82f1e5a8663 Mon Sep 17 00:00:00 2001 From: Sam Harwell Date: Wed, 27 Feb 2013 19:50:15 -0600 Subject: [PATCH] Use as+nullcheck instead of is+cast --- .../org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg index da862b011..5b8c2a5f5 100644 --- a/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg +++ b/tool/resources/org/antlr/v4/tool/templates/codegen/CSharp/CSharp.stg @@ -753,13 +753,15 @@ public partial class : Context { ListenerDispatchMethod(method) ::= << public override void EnterExitRule(IParseTreeListener listener) { - if ( listener is IListener ) ((IListener)listener).EnterExit(this); + IListener typedListener = listener as IListener; + if (typedListener != null) typedListener.EnterExit(this); } >> VisitorDispatchMethod(method) ::= << public override TResult Accept\(IParseTreeVisitor\ visitor) { - if ( visitor is IVisitor\ ) return ((IVisitor\)visitor).Visit(this); + IVisitor\ typedVisitor = visitor as IVisitor\; + if (typedVisitor != null) return typedVisitor.Visit(this); else return visitor.VisitChildren(this); } >>