Browse Source

ParameterCanBeDemotedIssue: remove GetInheritanceDepth.

It has the potential for a stack overflow when there's cyclic inheritance.
The sorting already done by GetAllBaseTypes() should be good enough.
pull/32/merge
Daniel Grunwald 13 years ago
parent
commit
6e6cf735a3
  1. 11
      ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/ParameterCanBeDemotedIssue.cs

11
ICSharpCode.NRefactory.CSharp/Refactoring/CodeIssues/ParameterCanBeDemotedIssue/ParameterCanBeDemotedIssue.cs

@ -145,7 +145,6 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -145,7 +145,6 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
var validTypes =
(from type in possibleTypes
where !tryResolve || TypeChangeResolvesCorrectly(parameter, rootResolutionNode, type)
orderby GetInheritanceDepth(type) ascending
select type).ToList();
if (validTypes.Any()) {
// don't demote an array to IList
@ -185,16 +184,6 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -185,16 +184,6 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
});
}
}
int GetInheritanceDepth(IType declaringType)
{
var depth = 0;
foreach (var baseType in declaringType.DirectBaseTypes) {
var newDepth = GetInheritanceDepth(baseType);
depth = Math.Max(depth, newDepth);
}
return depth;
}
}
class TypeChangeValidationNavigator : IResolveVisitorNavigator

Loading…
Cancel
Save