1 | // Copyright (c) 2010-2013 AlphaSierraPapa for the SharpDevelop Team |
---|
2 | // |
---|
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: |
---|
8 | // |
---|
9 | // The above copyright notice and this permission notice shall be included in all copies or |
---|
10 | // substantial portions of the Software. |
---|
11 | // |
---|
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. |
---|
18 | |
---|
19 | using System; |
---|
20 | using System.Collections.Generic; |
---|
21 | using System.Diagnostics.Contracts; |
---|
22 | using ICSharpCode.NRefactory.TypeSystem; |
---|
23 | |
---|
24 | namespace ICSharpCode.NRefactory.TypeSystem |
---|
25 | { |
---|
26 | /// <summary> |
---|
27 | /// Type parameter of a generic class/method. |
---|
28 | /// </summary> |
---|
29 | public interface IUnresolvedTypeParameter : INamedElement |
---|
30 | { |
---|
31 | /// <summary> |
---|
32 | /// Get the type of this type parameter's owner. |
---|
33 | /// </summary> |
---|
34 | /// <returns>SymbolKind.TypeDefinition or SymbolKind.Method</returns> |
---|
35 | SymbolKind OwnerType { get; } |
---|
36 | |
---|
37 | /// <summary> |
---|
38 | /// Gets the index of the type parameter in the type parameter list of the owning method/class. |
---|
39 | /// </summary> |
---|
40 | int Index { get; } |
---|
41 | |
---|
42 | /// <summary> |
---|
43 | /// Gets the list of attributes declared on this type parameter. |
---|
44 | /// </summary> |
---|
45 | IList<IUnresolvedAttribute> Attributes { get; } |
---|
46 | |
---|
47 | /// <summary> |
---|
48 | /// Gets the variance of this type parameter. |
---|
49 | /// </summary> |
---|
50 | VarianceModifier Variance { get; } |
---|
51 | |
---|
52 | /// <summary> |
---|
53 | /// Gets the region where the type parameter is defined. |
---|
54 | /// </summary> |
---|
55 | DomRegion Region { get; } |
---|
56 | |
---|
57 | ITypeParameter CreateResolvedTypeParameter(ITypeResolveContext context); |
---|
58 | } |
---|
59 | |
---|
60 | /// <summary> |
---|
61 | /// Type parameter of a generic class/method. |
---|
62 | /// </summary> |
---|
63 | public interface ITypeParameter : IType, ISymbol |
---|
64 | { |
---|
65 | /// <summary> |
---|
66 | /// Get the type of this type parameter's owner. |
---|
67 | /// </summary> |
---|
68 | /// <returns>SymbolKind.TypeDefinition or SymbolKind.Method</returns> |
---|
69 | SymbolKind OwnerType { get; } |
---|
70 | |
---|
71 | /// <summary> |
---|
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"/>). |
---|
74 | /// </summary> |
---|
75 | /// <remarks> |
---|
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. |
---|
79 | /// </remarks> |
---|
80 | IEntity Owner { get; } |
---|
81 | |
---|
82 | /// <summary> |
---|
83 | /// Gets the index of the type parameter in the type parameter list of the owning method/class. |
---|
84 | /// </summary> |
---|
85 | int Index { get; } |
---|
86 | |
---|
87 | /// <summary> |
---|
88 | /// Gets the name of the type parameter. |
---|
89 | /// </summary> |
---|
90 | new string Name { get; } |
---|
91 | |
---|
92 | /// <summary> |
---|
93 | /// Gets the list of attributes declared on this type parameter. |
---|
94 | /// </summary> |
---|
95 | IList<IAttribute> Attributes { get; } |
---|
96 | |
---|
97 | /// <summary> |
---|
98 | /// Gets the variance of this type parameter. |
---|
99 | /// </summary> |
---|
100 | VarianceModifier Variance { get; } |
---|
101 | |
---|
102 | /// <summary> |
---|
103 | /// Gets the region where the type parameter is defined. |
---|
104 | /// </summary> |
---|
105 | DomRegion Region { get; } |
---|
106 | |
---|
107 | /// <summary> |
---|
108 | /// Gets the effective base class of this type parameter. |
---|
109 | /// </summary> |
---|
110 | IType EffectiveBaseClass { get; } |
---|
111 | |
---|
112 | /// <summary> |
---|
113 | /// Gets the effective interface set of this type parameter. |
---|
114 | /// </summary> |
---|
115 | ICollection<IType> EffectiveInterfaceSet { get; } |
---|
116 | |
---|
117 | /// <summary> |
---|
118 | /// Gets if the type parameter has the 'new()' constraint. |
---|
119 | /// </summary> |
---|
120 | bool HasDefaultConstructorConstraint { get; } |
---|
121 | |
---|
122 | /// <summary> |
---|
123 | /// Gets if the type parameter has the 'class' constraint. |
---|
124 | /// </summary> |
---|
125 | bool HasReferenceTypeConstraint { get; } |
---|
126 | |
---|
127 | /// <summary> |
---|
128 | /// Gets if the type parameter has the 'struct' constraint. |
---|
129 | /// </summary> |
---|
130 | bool HasValueTypeConstraint { get; } |
---|
131 | } |
---|
132 | |
---|
133 | /// <summary> |
---|
134 | /// Represents the variance of a type parameter. |
---|
135 | /// </summary> |
---|
136 | public enum VarianceModifier : byte |
---|
137 | { |
---|
138 | /// <summary> |
---|
139 | /// The type parameter is not variant. |
---|
140 | /// </summary> |
---|
141 | Invariant, |
---|
142 | /// <summary> |
---|
143 | /// The type parameter is covariant (used in output position). |
---|
144 | /// </summary> |
---|
145 | Covariant, |
---|
146 | /// <summary> |
---|
147 | /// The type parameter is contravariant (used in input position). |
---|
148 | /// </summary> |
---|
149 | Contravariant |
---|
150 | }; |
---|
151 | } |
---|