diff options
author | Daniel Grunwald <daniel@danielgrunwald.de> | 2016-06-12 16:43:32 +0300 |
---|---|---|
committer | Daniel Grunwald <daniel@danielgrunwald.de> | 2016-06-12 16:43:32 +0300 |
commit | 16495d058b4ca39c0fe2a60f09a0f5b7bb2faf58 (patch) | |
tree | 1162eda928b290d8f23cc8077bae085ce68d6d2e | |
parent | 79f9a95f93003ad77214be22a1c31387d24e5491 (diff) |
Fix repeated specialization of non-generic members.
4 files changed, 28 insertions, 6 deletions
diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedEvent.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedEvent.cs index 3fb51217..2335b788 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedEvent.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedEvent.cs @@ -61,8 +61,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public override IMember Specialize(TypeParameterSubstitution substitution) { - if (TypeParameterSubstitution.Identity.Equals(substitution)) + if (TypeParameterSubstitution.Identity.Equals(substitution) + || DeclaringTypeDefinition == null + || DeclaringTypeDefinition.TypeParameterCount == 0) + { return this; + } + if (substitution.MethodTypeArguments != null && substitution.MethodTypeArguments.Count > 0) + substitution = new TypeParameterSubstitution(substitution.ClassTypeArguments, EmptyList<IType>.Instance); return new SpecializedEvent(this, substitution); } } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedField.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedField.cs index 8bb2317f..16981d2b 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedField.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedField.cs @@ -74,8 +74,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public override IMember Specialize(TypeParameterSubstitution substitution) { - if (TypeParameterSubstitution.Identity.Equals(substitution)) + if (TypeParameterSubstitution.Identity.Equals(substitution) + || DeclaringTypeDefinition == null + || DeclaringTypeDefinition.TypeParameterCount == 0) + { return this; + } + if (substitution.MethodTypeArguments != null && substitution.MethodTypeArguments.Count > 0) + substitution = new TypeParameterSubstitution(substitution.ClassTypeArguments, EmptyList<IType>.Instance); return new SpecializedField(this, substitution); } diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs index 0f6ebf72..0dc9bcc5 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs @@ -256,14 +256,18 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation { if (TypeParameterSubstitution.Identity.Equals(substitution)) return this; + if (TypeParameters.Count == 0) { + if (DeclaringTypeDefinition == null || DeclaringTypeDefinition.TypeParameterCount == 0) + return this; + if (substitution.MethodTypeArguments != null && substitution.MethodTypeArguments.Count > 0) + substitution = new TypeParameterSubstitution(substitution.ClassTypeArguments, EmptyList<IType>.Instance); + } return new SpecializedMethod(this, substitution); } IMethod IMethod.Specialize(TypeParameterSubstitution substitution) { - if (TypeParameterSubstitution.Identity.Equals(substitution)) - return this; - return new SpecializedMethod(this, substitution); + return (IMethod)Specialize(substitution); } public override string ToString() diff --git a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedProperty.cs b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedProperty.cs index 0ddb9549..69b477f8 100644 --- a/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedProperty.cs +++ b/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedProperty.cs @@ -100,8 +100,14 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation public override IMember Specialize(TypeParameterSubstitution substitution) { - if (TypeParameterSubstitution.Identity.Equals(substitution)) + if (TypeParameterSubstitution.Identity.Equals(substitution) + || DeclaringTypeDefinition == null + || DeclaringTypeDefinition.TypeParameterCount == 0) + { return this; + } + if (substitution.MethodTypeArguments != null && substitution.MethodTypeArguments.Count > 0) + substitution = new TypeParameterSubstitution(substitution.ClassTypeArguments, EmptyList<IType>.Instance); return new SpecializedProperty(this, substitution); } } |