|
|
@ -16,6 +16,7 @@ |
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
// DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
using ICSharpCode.Decompiler.Util; |
|
|
|
using ICSharpCode.Decompiler.Util; |
|
|
|
|
|
|
|
|
|
|
@ -43,10 +44,10 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
|
|
|
this.hasReferenceTypeConstraint = hasReferenceTypeConstraint; |
|
|
|
this.hasReferenceTypeConstraint = hasReferenceTypeConstraint; |
|
|
|
this.hasDefaultConstructorConstraint = hasDefaultConstructorConstraint; |
|
|
|
this.hasDefaultConstructorConstraint = hasDefaultConstructorConstraint; |
|
|
|
this.nullabilityConstraint = nullabilityConstraint; |
|
|
|
this.nullabilityConstraint = nullabilityConstraint; |
|
|
|
this.constraints = constraints ?? EmptyList<IType>.Instance; |
|
|
|
this.TypeConstraints = MakeConstraints(constraints); |
|
|
|
this.attributes = attributes ?? EmptyList<IAttribute>.Instance; |
|
|
|
this.attributes = attributes ?? EmptyList<IAttribute>.Instance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public DefaultTypeParameter( |
|
|
|
public DefaultTypeParameter( |
|
|
|
ICompilation compilation, SymbolKind ownerType, |
|
|
|
ICompilation compilation, SymbolKind ownerType, |
|
|
|
int index, string name = null, |
|
|
|
int index, string name = null, |
|
|
@ -60,7 +61,7 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
|
|
|
this.hasReferenceTypeConstraint = hasReferenceTypeConstraint; |
|
|
|
this.hasReferenceTypeConstraint = hasReferenceTypeConstraint; |
|
|
|
this.hasDefaultConstructorConstraint = hasDefaultConstructorConstraint; |
|
|
|
this.hasDefaultConstructorConstraint = hasDefaultConstructorConstraint; |
|
|
|
this.nullabilityConstraint = nullabilityConstraint; |
|
|
|
this.nullabilityConstraint = nullabilityConstraint; |
|
|
|
this.constraints = constraints ?? EmptyList<IType>.Instance; |
|
|
|
this.TypeConstraints = MakeConstraints(constraints); |
|
|
|
this.attributes = attributes ?? EmptyList<IAttribute>.Instance; |
|
|
|
this.attributes = attributes ?? EmptyList<IAttribute>.Instance; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -72,19 +73,24 @@ namespace ICSharpCode.Decompiler.TypeSystem.Implementation |
|
|
|
public override bool HasUnmanagedConstraint => false; |
|
|
|
public override bool HasUnmanagedConstraint => false; |
|
|
|
public override Nullability NullabilityConstraint => nullabilityConstraint; |
|
|
|
public override Nullability NullabilityConstraint => nullabilityConstraint; |
|
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<IType> DirectBaseTypes { |
|
|
|
public override IReadOnlyList<TypeConstraint> TypeConstraints { get; } |
|
|
|
get { |
|
|
|
|
|
|
|
bool hasNonInterfaceConstraint = false; |
|
|
|
IReadOnlyList<TypeConstraint> MakeConstraints(IReadOnlyList<IType> constraints) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
var result = new List<TypeConstraint>(); |
|
|
|
|
|
|
|
bool hasNonInterfaceConstraint = false; |
|
|
|
|
|
|
|
if (constraints != null) { |
|
|
|
foreach (IType c in constraints) { |
|
|
|
foreach (IType c in constraints) { |
|
|
|
yield return c; |
|
|
|
result.Add(new TypeConstraint(c)); |
|
|
|
if (c.Kind != TypeKind.Interface) |
|
|
|
if (c.Kind != TypeKind.Interface) |
|
|
|
hasNonInterfaceConstraint = true; |
|
|
|
hasNonInterfaceConstraint = true; |
|
|
|
} |
|
|
|
} |
|
|
|
// Do not add the 'System.Object' constraint if there is another constraint with a base class.
|
|
|
|
|
|
|
|
if (this.HasValueTypeConstraint || !hasNonInterfaceConstraint) { |
|
|
|
|
|
|
|
yield return this.Compilation.FindType(this.HasValueTypeConstraint ? KnownTypeCode.ValueType : KnownTypeCode.Object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Do not add the 'System.Object' constraint if there is another constraint with a base class.
|
|
|
|
|
|
|
|
if (this.HasValueTypeConstraint || !hasNonInterfaceConstraint) { |
|
|
|
|
|
|
|
result.Add(new TypeConstraint(this.Compilation.FindType(this.HasValueTypeConstraint ? KnownTypeCode.ValueType : KnownTypeCode.Object))); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|