180 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)
415
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds() => ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\LocalFunctionSymbol.cs (2)
29
private ImmutableArray<
TypeParameterConstraintKind
> _lazyTypeParameterConstraintKinds;
506
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)
156
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
157
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceDestructorSymbol.cs (2)
118
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
119
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceEventAccessorSymbol.cs (2)
194
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
195
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceMethodSymbol.cs (1)
32
public abstract ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds();
Symbols\Source\SourceNamedTypeSymbol.cs (38)
298
internal
TypeParameterConstraintKind
GetTypeParameterConstraintKind(int ordinal)
301
return (constraintKinds.Length > 0) ? constraintKinds[ordinal] :
TypeParameterConstraintKind
.None;
304
private ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
398
private ImmutableArray<
TypeParameterConstraintKind
> MakeTypeParameterConstraintKinds()
457
if (results.All(clause => clause.Constraints ==
TypeParameterConstraintKind
.None))
518
bool report = (GetTypeParameterConstraintKind(i) &
TypeParameterConstraintKind
.PartialMismatch) != 0;
665
TypeParameterConstraintKind
mergedKind = constraint.Constraints;
675
Debug.Assert((constraint.Constraints & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)) ==
676
(mergedKind & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)));
677
Debug.Assert((mergedKind &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0 ||
678
(constraint.Constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0);
679
Debug.Assert((constraint.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds) == (mergedKind &
TypeParameterConstraintKind
.AllReferenceTypeKinds) ||
680
(constraint.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds) ==
TypeParameterConstraintKind
.ReferenceType);
699
static void mergeConstraints(ref
TypeParameterConstraintKind
mergedKind, ImmutableArray<TypeWithAnnotations> originalConstraintTypes, TypeParameterConstraintClause clause)
701
if ((mergedKind & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)) != (clause.Constraints & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)))
703
mergedKind |=
TypeParameterConstraintKind
.PartialMismatch;
706
if ((mergedKind &
TypeParameterConstraintKind
.ReferenceType) != 0 && (clause.Constraints &
TypeParameterConstraintKind
.ReferenceType) != 0)
709
TypeParameterConstraintKind
clause1Constraints = mergedKind &
TypeParameterConstraintKind
.AllReferenceTypeKinds;
710
TypeParameterConstraintKind
clause2Constraints = clause.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds;
713
if (clause1Constraints ==
TypeParameterConstraintKind
.ReferenceType) // Oblivious
716
mergedKind = (mergedKind & (~
TypeParameterConstraintKind
.AllReferenceTypeKinds)) | clause2Constraints;
718
else if (clause2Constraints !=
TypeParameterConstraintKind
.ReferenceType)
721
mergedKind |=
TypeParameterConstraintKind
.PartialMismatch;
729
if (((mergedKind | clause.Constraints) & ~(
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType |
TypeParameterConstraintKind
.Constructor)) == 0 &&
730
(mergedKind &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0 && // 'object~'
731
(clause.Constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0) // 'object?'
734
mergedKind &= ~
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType;
Symbols\Source\SourceOrdinaryMethodSymbol.cs (11)
195
(args.declaredConstraints[typeParameterSymbol.Ordinal].Constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.Default)) == 0;
658
switch (declaredConstraints[i].Constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.Default))
660
case
TypeParameterConstraintKind
.ReferenceType:
667
case
TypeParameterConstraintKind
.ValueType:
674
case
TypeParameterConstraintKind
.Default:
970
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
971
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
1084
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
Symbols\Source\SourcePropertyAccessorSymbol.cs (2)
343
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
344
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceTypeParameterSymbol.cs (44)
441
protected bool? CalculateReferenceTypeConstraintIsNullable(
TypeParameterConstraintKind
constraints)
443
if ((constraints &
TypeParameterConstraintKind
.ReferenceType) == 0)
448
switch (constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds)
450
case
TypeParameterConstraintKind
.NullableReferenceType:
452
case
TypeParameterConstraintKind
.NotNullableReferenceType:
494
var
constraints = this.GetConstraintKinds();
495
return (constraints &
TypeParameterConstraintKind
.Constructor) != 0;
503
var
constraints = this.GetConstraintKinds();
504
return (constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0;
512
var
constraints = this.GetConstraintKinds();
513
return (constraints &
TypeParameterConstraintKind
.AllowByRefLike) != 0;
522
var
constraints = this.GetConstraintKinds();
523
return (constraints &
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes) != 0;
531
var
constraints = this.GetConstraintKinds();
532
return (constraints &
TypeParameterConstraintKind
.ReferenceType) != 0;
540
var
constraints = this.GetConstraintKinds();
541
return (constraints &
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes) != 0;
557
var
constraints = this.GetConstraintKinds();
558
return (constraints &
TypeParameterConstraintKind
.NotNull) != 0;
566
if ((this.GetConstraintKinds() &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0)
579
var
constraints = this.GetConstraintKinds();
580
return (constraints &
TypeParameterConstraintKind
.Unmanaged) != 0;
592
if (constraintTypes.IsEmpty && GetConstraintKinds() ==
TypeParameterConstraintKind
.None)
600
private
TypeParameterConstraintKind
GetConstraintKinds()
675
var
constraints = this.GetConstraintKinds();
676
return (constraints &
TypeParameterConstraintKind
.Constructor) != 0;
684
var
constraints = this.GetConstraintKinds();
685
return (constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0;
693
var
constraints = this.GetConstraintKinds();
694
return (constraints &
TypeParameterConstraintKind
.AllowByRefLike) != 0;
703
var
constraints = this.GetConstraintKinds();
704
return (constraints &
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes) != 0;
712
var
constraints = this.GetConstraintKinds();
713
return (constraints &
TypeParameterConstraintKind
.ReferenceType) != 0;
721
var
constraints = this.GetConstraintKinds();
722
return (constraints &
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes) != 0;
730
var
constraints = this.GetConstraintKinds();
731
return (constraints &
TypeParameterConstraintKind
.NotNull) != 0;
747
if ((this.GetConstraintKinds() &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0)
760
var
constraints = this.GetConstraintKinds();
761
return (constraints &
TypeParameterConstraintKind
.Unmanaged) != 0;
770
if (constraintTypes.IsEmpty && GetConstraintKinds() ==
TypeParameterConstraintKind
.None)
778
private
TypeParameterConstraintKind
GetConstraintKinds()
781
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)
205
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
206
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Microsoft.CodeAnalysis.CSharp.Test.Utilities (2)
CompilationTestUtils.cs (2)
171
var
constraints = TypeParameterConstraintKind.None;
189
var
constraints = TypeParameterConstraintKind.None;