Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xamarin/NRefactory.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Grunwald <daniel@danielgrunwald.de>2016-06-12 16:43:32 +0300
committerDaniel Grunwald <daniel@danielgrunwald.de>2016-06-12 16:43:32 +0300
commit16495d058b4ca39c0fe2a60f09a0f5b7bb2faf58 (patch)
tree1162eda928b290d8f23cc8077bae085ce68d6d2e
parent79f9a95f93003ad77214be22a1c31387d24e5491 (diff)
Fix repeated specialization of non-generic members.
-rw-r--r--ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedEvent.cs8
-rw-r--r--ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedField.cs8
-rw-r--r--ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs10
-rw-r--r--ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedProperty.cs8
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);
}
}