178 references to TypeParameterConstraintKind
Microsoft.CodeAnalysis.CSharp (178)
Binder\Binder_Constraints.cs (28)
121
var
constraints =
TypeParameterConstraintKind
.None;
144
if (isForOverride && (constraints & (
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.ReferenceType)) != 0)
154
constraints |=
TypeParameterConstraintKind
.NullableReferenceType;
167
constraints |=
TypeParameterConstraintKind
.NotNullableReferenceType;
171
constraints |=
TypeParameterConstraintKind
.ReferenceType;
185
if (isForOverride && (constraints & (
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.ReferenceType)) != 0)
191
constraints |=
TypeParameterConstraintKind
.ValueType;
200
if ((constraints &
TypeParameterConstraintKind
.ValueType) != 0)
204
if ((constraints &
TypeParameterConstraintKind
.Unmanaged) != 0)
214
constraints |=
TypeParameterConstraintKind
.Constructor;
231
if (isForOverride && (constraints & (
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.ReferenceType)) != 0)
237
constraints |=
TypeParameterConstraintKind
.Default;
272
constraints |=
TypeParameterConstraintKind
.Unmanaged;
281
constraints |=
TypeParameterConstraintKind
.NotNull;
327
constraints |=
TypeParameterConstraintKind
.AllowByRefLike;
342
constraints |=
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType;
346
(constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType)) != (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType));
487
TypeParameterConstraintKind
constraints,
518
if ((constraints & (
TypeParameterConstraintKind
.ReferenceType)) != 0)
535
if ((constraints &
TypeParameterConstraintKind
.ValueType) != 0)
541
else if ((constraints &
TypeParameterConstraintKind
.Unmanaged) != 0)
Lowering\SynthesizedMethodBaseSymbol.cs (2)
84
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
85
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\ConstraintsHelper.cs (10)
374
internal static ImmutableArray<
TypeParameterConstraintKind
> MakeTypeParameterConstraintKinds(
383
return ImmutableArray<
TypeParameterConstraintKind
>.Empty;
407
if (clauses.All(clause => clause.Constraints ==
TypeParameterConstraintKind
.None))
409
return ImmutableArray<
TypeParameterConstraintKind
>.Empty;
429
TypeParameterConstraintKind
constraintKind = constraint.Constraints;
431
Debug.Assert((constraintKind & (
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes |
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes)) == 0);
433
if ((constraintKind &
TypeParameterConstraintKind
.AllValueTypeKinds) == 0 && isValueTypeMap[typeParameter])
435
constraintKind |=
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes;
440
constraintKind |=
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes;
Symbols\Source\LambdaSymbol.cs (2)
434
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds() => ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\LocalFunctionSymbol.cs (2)
29
private ImmutableArray<
TypeParameterConstraintKind
> _lazyTypeParameterConstraintKinds;
531
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
Symbols\Source\SourceConstructorSymbolBase.cs (2)
148
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
149
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceDelegateMethodSymbol.cs (2)
159
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
160
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceDestructorSymbol.cs (2)
121
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
122
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceEventAccessorSymbol.cs (2)
194
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
195
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceMethodSymbol.cs (1)
30
public abstract ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds();
Symbols\Source\SourceNamedTypeSymbol.cs (38)
302
internal
TypeParameterConstraintKind
GetTypeParameterConstraintKind(int ordinal)
305
return (constraintKinds.Length > 0) ? constraintKinds[ordinal] :
TypeParameterConstraintKind
.None;
308
private ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
402
private ImmutableArray<
TypeParameterConstraintKind
> MakeTypeParameterConstraintKinds()
461
if (results.All(clause => clause.Constraints ==
TypeParameterConstraintKind
.None))
523
bool report = (GetTypeParameterConstraintKind(i) &
TypeParameterConstraintKind
.PartialMismatch) != 0;
670
TypeParameterConstraintKind
mergedKind = constraint.Constraints;
680
Debug.Assert((constraint.Constraints & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)) ==
681
(mergedKind & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)));
682
Debug.Assert((mergedKind &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0 ||
683
(constraint.Constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0);
684
Debug.Assert((constraint.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds) == (mergedKind &
TypeParameterConstraintKind
.AllReferenceTypeKinds) ||
685
(constraint.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds) ==
TypeParameterConstraintKind
.ReferenceType);
704
static void mergeConstraints(ref
TypeParameterConstraintKind
mergedKind, ImmutableArray<TypeWithAnnotations> originalConstraintTypes, TypeParameterConstraintClause clause)
706
if ((mergedKind & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)) != (clause.Constraints & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)))
708
mergedKind |=
TypeParameterConstraintKind
.PartialMismatch;
711
if ((mergedKind &
TypeParameterConstraintKind
.ReferenceType) != 0 && (clause.Constraints &
TypeParameterConstraintKind
.ReferenceType) != 0)
714
TypeParameterConstraintKind
clause1Constraints = mergedKind &
TypeParameterConstraintKind
.AllReferenceTypeKinds;
715
TypeParameterConstraintKind
clause2Constraints = clause.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds;
718
if (clause1Constraints ==
TypeParameterConstraintKind
.ReferenceType) // Oblivious
721
mergedKind = (mergedKind & (~
TypeParameterConstraintKind
.AllReferenceTypeKinds)) | clause2Constraints;
723
else if (clause2Constraints !=
TypeParameterConstraintKind
.ReferenceType)
726
mergedKind |=
TypeParameterConstraintKind
.PartialMismatch;
734
if (((mergedKind | clause.Constraints) & ~(
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType |
TypeParameterConstraintKind
.Constructor)) == 0 &&
735
(mergedKind &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0 && // 'object~'
736
(clause.Constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0) // 'object?'
739
mergedKind &= ~
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType;
Symbols\Source\SourceOrdinaryMethodSymbol.cs (11)
196
(args.declaredConstraints[typeParameterSymbol.Ordinal].Constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.Default)) == 0;
678
switch (declaredConstraints[i].Constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.Default))
680
case
TypeParameterConstraintKind
.ReferenceType:
687
case
TypeParameterConstraintKind
.ValueType:
694
case
TypeParameterConstraintKind
.Default:
990
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
991
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
1104
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
Symbols\Source\SourcePropertyAccessorSymbol.cs (2)
373
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
374
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceTypeParameterSymbol.cs (44)
431
protected bool? CalculateReferenceTypeConstraintIsNullable(
TypeParameterConstraintKind
constraints)
433
if ((constraints &
TypeParameterConstraintKind
.ReferenceType) == 0)
438
switch (constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds)
440
case
TypeParameterConstraintKind
.NullableReferenceType:
442
case
TypeParameterConstraintKind
.NotNullableReferenceType:
484
var
constraints = this.GetConstraintKinds();
485
return (constraints &
TypeParameterConstraintKind
.Constructor) != 0;
493
var
constraints = this.GetConstraintKinds();
494
return (constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0;
502
var
constraints = this.GetConstraintKinds();
503
return (constraints &
TypeParameterConstraintKind
.AllowByRefLike) != 0;
512
var
constraints = this.GetConstraintKinds();
513
return (constraints &
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes) != 0;
521
var
constraints = this.GetConstraintKinds();
522
return (constraints &
TypeParameterConstraintKind
.ReferenceType) != 0;
530
var
constraints = this.GetConstraintKinds();
531
return (constraints &
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes) != 0;
547
var
constraints = this.GetConstraintKinds();
548
return (constraints &
TypeParameterConstraintKind
.NotNull) != 0;
556
if ((this.GetConstraintKinds() &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0)
569
var
constraints = this.GetConstraintKinds();
570
return (constraints &
TypeParameterConstraintKind
.Unmanaged) != 0;
582
if (constraintTypes.IsEmpty && GetConstraintKinds() ==
TypeParameterConstraintKind
.None)
590
private
TypeParameterConstraintKind
GetConstraintKinds()
665
var
constraints = this.GetConstraintKinds();
666
return (constraints &
TypeParameterConstraintKind
.Constructor) != 0;
674
var
constraints = this.GetConstraintKinds();
675
return (constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0;
683
var
constraints = this.GetConstraintKinds();
684
return (constraints &
TypeParameterConstraintKind
.AllowByRefLike) != 0;
693
var
constraints = this.GetConstraintKinds();
694
return (constraints &
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes) != 0;
702
var
constraints = this.GetConstraintKinds();
703
return (constraints &
TypeParameterConstraintKind
.ReferenceType) != 0;
711
var
constraints = this.GetConstraintKinds();
712
return (constraints &
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes) != 0;
720
var
constraints = this.GetConstraintKinds();
721
return (constraints &
TypeParameterConstraintKind
.NotNull) != 0;
737
if ((this.GetConstraintKinds() &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0)
750
var
constraints = this.GetConstraintKinds();
751
return (constraints &
TypeParameterConstraintKind
.Unmanaged) != 0;
760
if (constraintTypes.IsEmpty && GetConstraintKinds() ==
TypeParameterConstraintKind
.None)
768
private
TypeParameterConstraintKind
GetConstraintKinds()
771
return constraintKinds.IsEmpty ?
TypeParameterConstraintKind
.None : constraintKinds[Ordinal];
Symbols\Source\SourceUserDefinedOperatorSymbolBase.cs (2)
1006
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
1007
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SynthesizedSourceOrdinaryMethodSymbol.cs (2)
46
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds() => ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\TypeParameterConstraintClause.cs (22)
43
/// <see cref="
TypeParameterConstraintKind
"/> mismatch is detected during merging process for partial type declarations.
74
TypeParameterConstraintKind
.None,
78
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType,
82
TypeParameterConstraintKind
constraints,
90
case
TypeParameterConstraintKind
.None:
93
case
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType:
102
TypeParameterConstraintKind
constraints,
106
switch (constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds)
108
case
TypeParameterConstraintKind
.None:
109
case
TypeParameterConstraintKind
.ReferenceType:
110
case
TypeParameterConstraintKind
.NullableReferenceType:
111
case
TypeParameterConstraintKind
.NotNullableReferenceType:
118
Debug.Assert((constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0 ||
119
(constraints & ~(
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType |
TypeParameterConstraintKind
.Constructor |
120
TypeParameterConstraintKind
.Default |
TypeParameterConstraintKind
.PartialMismatch |
121
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes |
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes |
122
TypeParameterConstraintKind
.AllowByRefLike)) == 0);
128
public readonly
TypeParameterConstraintKind
Constraints;
162
if ((constraintClause.Constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0)
Symbols\Source\TypeParameterInfo.cs (2)
28
public ImmutableArray<
TypeParameterConstraintKind
> LazyTypeParameterConstraintKinds;
34
LazyTypeParameterConstraintKinds = ImmutableArray<
TypeParameterConstraintKind
>.Empty,
Symbols\Synthesized\SynthesizedSimpleProgramEntryPointSymbol.cs (2)
220
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
221
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;