1
// Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team
3
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
4
// software and associated documentation files (the "Software"), to deal in the Software
5
// without restriction, including without limitation the rights to use, copy, modify, merge,
6
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
7
// to whom the Software is furnished to do so, subject to the following conditions:
9
// The above copyright notice and this permission notice shall be included in all copies or
10
// substantial portions of the Software.
12
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
13
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
15
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17
// DEALINGS IN THE SOFTWARE.
20
using System.Collections.Generic;
21
using System.Diagnostics.Contracts;
22
using ICSharpCode.NRefactory.TypeSystem;
24
namespace ICSharpCode.NRefactory.TypeSystem
27
/// Type parameter of a generic class/method.
29
public interface IUnresolvedTypeParameter : INamedElement
32
/// Get the type of this type parameter's owner.
34
/// <returns>EntityType.TypeDefinition or EntityType.Method</returns>
35
EntityType OwnerType { get; }
38
/// Gets the index of the type parameter in the type parameter list of the owning method/class.
43
/// Gets the list of attributes declared on this type parameter.
45
IList<IUnresolvedAttribute> Attributes { get; }
48
/// Gets the variance of this type parameter.
50
VarianceModifier Variance { get; }
53
/// Gets the region where the type parameter is defined.
55
DomRegion Region { get; }
57
ITypeParameter CreateResolvedTypeParameter(ITypeResolveContext context);
61
/// Type parameter of a generic class/method.
63
public interface ITypeParameter : IType
66
/// Get the type of this type parameter's owner.
68
/// <returns>EntityType.TypeDefinition or EntityType.Method</returns>
69
EntityType OwnerType { get; }
72
/// Gets the owning method/class.
73
/// This property may return null (for example for the dummy type parameters used by <see cref="ParameterListComparer.NormalizeMethodTypeParameters"/>).
76
/// For "class Outer<T> { class Inner {} }",
77
/// inner.TypeParameters[0].Owner will be the outer class, because the same
78
/// ITypeParameter instance is used both on Outer`1 and Outer`1+Inner.
80
IEntity Owner { get; }
83
/// Gets the index of the type parameter in the type parameter list of the owning method/class.
88
/// Gets the list of attributes declared on this type parameter.
90
IList<IAttribute> Attributes { get; }
93
/// Gets the variance of this type parameter.
95
VarianceModifier Variance { get; }
98
/// Gets the region where the type parameter is defined.
100
DomRegion Region { get; }
103
/// Gets the effective base class of this type parameter.
105
IType EffectiveBaseClass { get; }
108
/// Gets the effective interface set of this type parameter.
110
ICollection<IType> EffectiveInterfaceSet { get; }
113
/// Gets if the type parameter has the 'new()' constraint.
115
bool HasDefaultConstructorConstraint { get; }
118
/// Gets if the type parameter has the 'class' constraint.
120
bool HasReferenceTypeConstraint { get; }
123
/// Gets if the type parameter has the 'struct' constraint.
125
bool HasValueTypeConstraint { get; }
129
/// Represents the variance of a type parameter.
131
public enum VarianceModifier : byte
134
/// The type parameter is not variant.
138
/// The type parameter is covariant (used in output position).
142
/// The type parameter is contravariant (used in input position).