diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Generics.cs b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Generics.cs index 0ff0b26a5..df65be4f2 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Generics.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Correctness/Generics.cs @@ -57,11 +57,35 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness } } - public class BaseClass + public abstract class BaseClass { + protected abstract void Method1(T test); } public class DerivedClass : BaseClass { + protected override void Method1(T test) { } + + private void Method2() + { + this.Method1(0); + } + } + + #region Issue 958 - Invalid cast in generic class for abstract base call + internal abstract class BaseClass + { + protected abstract void Method1(); + } + + internal class DerivedClass : BaseClass + { + protected override void Method1() { } + + private void Method2() + { + this.Method1(); + } } + #endregion } diff --git a/ICSharpCode.Decompiler/NRExtensions.cs b/ICSharpCode.Decompiler/NRExtensions.cs index 4e72c08ab..3f0a5c38a 100644 --- a/ICSharpCode.Decompiler/NRExtensions.cs +++ b/ICSharpCode.Decompiler/NRExtensions.cs @@ -31,7 +31,7 @@ namespace ICSharpCode.Decompiler if (decompilationContext.CurrentTypeDefinition != null) classTypeParameters = decompilationContext.CurrentTypeDefinition.TypeArguments; IMethod method = decompilationContext.CurrentMember as IMethod; - if (method != null) + if (method != null && method.TypeParameters.Count > 0) methodTypeParameters = method.TypeArguments; if (typeSystem is SpecializingDecompilerTypeSystem) typeSystem = ((SpecializingDecompilerTypeSystem)typeSystem).Context;