Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 6147f60

Browse files
committed
Fix ArgumentNullException in RedundantCatchClauseIssue.GatherVisitor.IsRedundant()
1 parent 9735fe9 commit 6147f60

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeIssues/Synced/RedundanciesInCode/RedundantCatchClauseIssue.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ bool IsRedundant(CatchClause catchClause)
146146
if (nextClause != null) {
147147
if (nextClause.Type.IsNull && !IsThrowsClause(nextClause))
148148
return false;
149-
if (!IsThrowsClause(nextClause) && type.GetDefinition ().IsDerivedFrom (ctx.Resolve (nextClause.Type).Type.GetDefinition ()))
150-
return false;
149+
if (!IsThrowsClause(nextClause)) {
150+
var typeDef = type.GetDefinition();
151+
if (typeDef == null || typeDef.IsDerivedFrom(ctx.Resolve(nextClause.Type).Type.GetDefinition()))
152+
return false;
153+
}
151154
}
152155
n = n.NextSibling;
153156
}

0 commit comments

Comments
 (0)