Browse Source

[Resolver] Fixed infinite loop issue when a type inherits from type

parameter.
newNRvisualizers
Mike Krüger 13 years ago
parent
commit
3dbba420eb
  1. 23
      ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolveAtLocationTests.cs
  2. 2
      ICSharpCode.NRefactory/TypeSystem/Implementation/BaseTypeCollector.cs

23
ICSharpCode.NRefactory.Tests/CSharp/Resolver/ResolveAtLocationTests.cs

@ -179,5 +179,28 @@ class Foo { @@ -179,5 +179,28 @@ class Foo {
}
}"));
}
[Test]
public void TestBug6758()
{
var rr = ResolveAtLocation<TypeResolveResult>(
@"using System;
namespace TestCrash
{
class A
{
}
class B<T> : T where T: $A
{
}
}
");
Assert.AreEqual("A", rr.Type.Name);
}
}
}

2
ICSharpCode.NRefactory/TypeSystem/Implementation/BaseTypeCollector.cs

@ -55,6 +55,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -55,6 +55,8 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
// (e.g. C implements I1 and I2, and both interfaces derive from Object)
if (!this.Contains(type)) {
foreach (IType baseType in type.DirectBaseTypes) {
if (type.Kind != TypeKind.TypeParameter && baseType.Kind == TypeKind.TypeParameter)
continue;
if (SkipImplementedInterfaces && def != null && def.Kind != TypeKind.Interface && def.Kind != TypeKind.TypeParameter) {
if (baseType.Kind == TypeKind.Interface) {
// skip the interface

Loading…
Cancel
Save