Browse Source

Moved SpecializedMember property 'Substitution' to IMember and

SpecializedMethod property 'TypeArguments' to IMethod.
That should eliminate the need to upcast these objects & makes the
type system more flexible - that's needed for the
ReducedExtensionMethod model.
pull/32/merge
Mike Krüger 13 years ago
parent
commit
d19a6d2c96
  1. 8
      ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs
  2. 17
      ICSharpCode.NRefactory.CSharp/Resolver/ReducedExtensionMethod.cs
  3. 9
      ICSharpCode.NRefactory/TypeSystem/IMember.cs
  4. 11
      ICSharpCode.NRefactory/TypeSystem/IMethod.cs
  5. 6
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs
  6. 5
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs

8
ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs

@ -227,7 +227,13 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver @@ -227,7 +227,13 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
{
throw new NotSupportedException();
}
TypeParameterSubstitution IMember.Substitution {
get {
return TypeParameterSubstitution.Identity;
}
}
string INamedElement.FullName {
get { return "operator"; }
}

17
ICSharpCode.NRefactory.CSharp/Resolver/ReducedExtensionMethod.cs

@ -27,6 +27,7 @@ using System; @@ -27,6 +27,7 @@ using System;
using ICSharpCode.NRefactory.TypeSystem;
using System.Collections.Generic;
using System.Linq;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp
{
@ -143,6 +144,13 @@ namespace ICSharpCode.NRefactory.CSharp @@ -143,6 +144,13 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
public TypeParameterSubstitution Substitution {
get {
return baseMethod.Substitution;
}
}
#endregion
#region IMethod implementation
@ -220,9 +228,16 @@ namespace ICSharpCode.NRefactory.CSharp @@ -220,9 +228,16 @@ namespace ICSharpCode.NRefactory.CSharp
}
public IMethod ReducedFrom {
get { return baseMethod; }
get {
return baseMethod;
}
}
public IList<IType> TypeArguments {
get {
return baseMethod.TypeArguments;
}
}
#endregion
#region IParameterizedMember implementation

9
ICSharpCode.NRefactory/TypeSystem/IMember.cs

@ -170,5 +170,14 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -170,5 +170,14 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Otherwise, the main resolve context of a compilation is sufficient.
/// </remarks>
IMemberReference ToMemberReference();
/// <summary>
/// Gets the substitution belonging to this specialized member.
/// Returns TypeParameterSubstitution.Identity for not specialized members.
/// </summary>
TypeParameterSubstitution Substitution {
get;
}
}
}

11
ICSharpCode.NRefactory/TypeSystem/IMethod.cs

@ -97,7 +97,16 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -97,7 +97,16 @@ namespace ICSharpCode.NRefactory.TypeSystem
IList<IAttribute> ReturnTypeAttributes { get; }
IList<ITypeParameter> TypeParameters { get; }
/// <summary>
/// Gets the type arguments passed to this method.
/// If only the type parameters for the class were specified and the generic method
/// itself is not specialized yet, this property will return an empty list.
/// </summary>
IList<IType> TypeArguments {
get;
}
bool IsExtensionMethod { get; }
bool IsConstructor { get; }
bool IsDestructor { get; }

6
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs

@ -117,7 +117,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -117,7 +117,11 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public bool IsOverridable {
get { return unresolved.IsOverridable; }
}
public TypeParameterSubstitution Substitution {
get { return TypeParameterSubstitution.Identity; }
}
public virtual IMemberReference ToMemberReference()
{
var declTypeRef = this.DeclaringType.ToTypeReference();

5
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs

@ -172,7 +172,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -172,7 +172,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public IList<IParameter> Parameters { get; private set; }
public IList<IAttribute> ReturnTypeAttributes { get; private set; }
public IList<ITypeParameter> TypeParameters { get; private set; }
static readonly IList<IType> emptyArguments = new IType[0];
public IList<IType> TypeArguments { get { return emptyArguments; } }
public bool IsExtensionMethod { get; private set; }
public IList<IUnresolvedMethod> Parts {

Loading…
Cancel
Save