180 references to TypeParameterConstraintKind
Microsoft.CodeAnalysis.CSharp (178)
Binder\Binder_Constraints.cs (28)
120
var
constraints =
TypeParameterConstraintKind
.None;
143
if (isForOverride && (constraints & (
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.ReferenceType)) != 0)
153
constraints |=
TypeParameterConstraintKind
.NullableReferenceType;
166
constraints |=
TypeParameterConstraintKind
.NotNullableReferenceType;
170
constraints |=
TypeParameterConstraintKind
.ReferenceType;
184
if (isForOverride && (constraints & (
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.ReferenceType)) != 0)
190
constraints |=
TypeParameterConstraintKind
.ValueType;
199
if ((constraints &
TypeParameterConstraintKind
.ValueType) != 0)
203
if ((constraints &
TypeParameterConstraintKind
.Unmanaged) != 0)
213
constraints |=
TypeParameterConstraintKind
.Constructor;
230
if (isForOverride && (constraints & (
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.ReferenceType)) != 0)
236
constraints |=
TypeParameterConstraintKind
.Default;
271
constraints |=
TypeParameterConstraintKind
.Unmanaged;
280
constraints |=
TypeParameterConstraintKind
.NotNull;
326
constraints |=
TypeParameterConstraintKind
.AllowByRefLike;
341
constraints |=
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType;
345
(constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType)) != (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType));
486
TypeParameterConstraintKind
constraints,
517
if ((constraints & (
TypeParameterConstraintKind
.ReferenceType)) != 0)
534
if ((constraints &
TypeParameterConstraintKind
.ValueType) != 0)
540
else if ((constraints &
TypeParameterConstraintKind
.Unmanaged) != 0)
Lowering\SynthesizedMethodBaseSymbol.cs (2)
99
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
100
=> 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)
429
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds() => ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\LocalFunctionSymbol.cs (2)
29
private ImmutableArray<
TypeParameterConstraintKind
> _lazyTypeParameterConstraintKinds;
500
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
Symbols\Source\SourceConstructorSymbolBase.cs (2)
140
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
141
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceDelegateMethodSymbol.cs (2)
155
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
156
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceDestructorSymbol.cs (2)
117
public override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
118
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceEventAccessorSymbol.cs (2)
194
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
195
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceMethodSymbol.cs (1)
29
public abstract ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds();
Symbols\Source\SourceNamedTypeSymbol.cs (38)
294
internal
TypeParameterConstraintKind
GetTypeParameterConstraintKind(int ordinal)
297
return (constraintKinds.Length > 0) ? constraintKinds[ordinal] :
TypeParameterConstraintKind
.None;
300
private ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
394
private ImmutableArray<
TypeParameterConstraintKind
> MakeTypeParameterConstraintKinds()
453
if (results.All(clause => clause.Constraints ==
TypeParameterConstraintKind
.None))
513
bool report = (GetTypeParameterConstraintKind(i) &
TypeParameterConstraintKind
.PartialMismatch) != 0;
660
TypeParameterConstraintKind
mergedKind = constraint.Constraints;
670
Debug.Assert((constraint.Constraints & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)) ==
671
(mergedKind & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)));
672
Debug.Assert((mergedKind &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0 ||
673
(constraint.Constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0);
674
Debug.Assert((constraint.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds) == (mergedKind &
TypeParameterConstraintKind
.AllReferenceTypeKinds) ||
675
(constraint.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds) ==
TypeParameterConstraintKind
.ReferenceType);
694
static void mergeConstraints(ref
TypeParameterConstraintKind
mergedKind, ImmutableArray<TypeWithAnnotations> originalConstraintTypes, TypeParameterConstraintClause clause)
696
if ((mergedKind & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)) != (clause.Constraints & (
TypeParameterConstraintKind
.AllNonNullableKinds |
TypeParameterConstraintKind
.NotNull)))
698
mergedKind |=
TypeParameterConstraintKind
.PartialMismatch;
701
if ((mergedKind &
TypeParameterConstraintKind
.ReferenceType) != 0 && (clause.Constraints &
TypeParameterConstraintKind
.ReferenceType) != 0)
704
TypeParameterConstraintKind
clause1Constraints = mergedKind &
TypeParameterConstraintKind
.AllReferenceTypeKinds;
705
TypeParameterConstraintKind
clause2Constraints = clause.Constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds;
708
if (clause1Constraints ==
TypeParameterConstraintKind
.ReferenceType) // Oblivious
711
mergedKind = (mergedKind & (~
TypeParameterConstraintKind
.AllReferenceTypeKinds)) | clause2Constraints;
713
else if (clause2Constraints !=
TypeParameterConstraintKind
.ReferenceType)
716
mergedKind |=
TypeParameterConstraintKind
.PartialMismatch;
724
if (((mergedKind | clause.Constraints) & ~(
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType |
TypeParameterConstraintKind
.Constructor)) == 0 &&
725
(mergedKind &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0 && // 'object~'
726
(clause.Constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0) // 'object?'
729
mergedKind &= ~
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType;
Symbols\Source\SourceOrdinaryMethodSymbol.cs (11)
194
(args.declaredConstraints[typeParameterSymbol.Ordinal].Constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.Default)) == 0;
648
switch (declaredConstraints[i].Constraints & (
TypeParameterConstraintKind
.ReferenceType |
TypeParameterConstraintKind
.ValueType |
TypeParameterConstraintKind
.Default))
650
case
TypeParameterConstraintKind
.ReferenceType:
657
case
TypeParameterConstraintKind
.ValueType:
664
case
TypeParameterConstraintKind
.Default:
944
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
945
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
1058
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
Symbols\Source\SourcePropertyAccessorSymbol.cs (2)
342
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
343
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\SourceTypeParameterSymbol.cs (44)
440
protected bool? CalculateReferenceTypeConstraintIsNullable(
TypeParameterConstraintKind
constraints)
442
if ((constraints &
TypeParameterConstraintKind
.ReferenceType) == 0)
447
switch (constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds)
449
case
TypeParameterConstraintKind
.NullableReferenceType:
451
case
TypeParameterConstraintKind
.NotNullableReferenceType:
493
var
constraints = this.GetConstraintKinds();
494
return (constraints &
TypeParameterConstraintKind
.Constructor) != 0;
502
var
constraints = this.GetConstraintKinds();
503
return (constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0;
511
var
constraints = this.GetConstraintKinds();
512
return (constraints &
TypeParameterConstraintKind
.AllowByRefLike) != 0;
521
var
constraints = this.GetConstraintKinds();
522
return (constraints &
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes) != 0;
530
var
constraints = this.GetConstraintKinds();
531
return (constraints &
TypeParameterConstraintKind
.ReferenceType) != 0;
539
var
constraints = this.GetConstraintKinds();
540
return (constraints &
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes) != 0;
556
var
constraints = this.GetConstraintKinds();
557
return (constraints &
TypeParameterConstraintKind
.NotNull) != 0;
565
if ((this.GetConstraintKinds() &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0)
578
var
constraints = this.GetConstraintKinds();
579
return (constraints &
TypeParameterConstraintKind
.Unmanaged) != 0;
591
if (constraintTypes.IsEmpty && GetConstraintKinds() ==
TypeParameterConstraintKind
.None)
599
private
TypeParameterConstraintKind
GetConstraintKinds()
635
var
constraints = this.GetConstraintKinds();
636
return (constraints &
TypeParameterConstraintKind
.Constructor) != 0;
644
var
constraints = this.GetConstraintKinds();
645
return (constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0;
653
var
constraints = this.GetConstraintKinds();
654
return (constraints &
TypeParameterConstraintKind
.AllowByRefLike) != 0;
663
var
constraints = this.GetConstraintKinds();
664
return (constraints &
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes) != 0;
672
var
constraints = this.GetConstraintKinds();
673
return (constraints &
TypeParameterConstraintKind
.ReferenceType) != 0;
681
var
constraints = this.GetConstraintKinds();
682
return (constraints &
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes) != 0;
690
var
constraints = this.GetConstraintKinds();
691
return (constraints &
TypeParameterConstraintKind
.NotNull) != 0;
707
if ((this.GetConstraintKinds() &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) != 0)
720
var
constraints = this.GetConstraintKinds();
721
return (constraints &
TypeParameterConstraintKind
.Unmanaged) != 0;
735
if (constraintTypes.IsEmpty && GetConstraintKinds() ==
TypeParameterConstraintKind
.None)
743
private
TypeParameterConstraintKind
GetConstraintKinds()
746
return constraintKinds.IsEmpty ?
TypeParameterConstraintKind
.None : constraintKinds[Ordinal];
Symbols\Source\SourceUserDefinedOperatorSymbolBase.cs (2)
785
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds()
786
=> ImmutableArray<
TypeParameterConstraintKind
>.Empty;
Symbols\Source\TypeParameterConstraintClause.cs (22)
44
/// <see cref="
TypeParameterConstraintKind
"/> mismatch is detected during merging process for partial type declarations.
75
TypeParameterConstraintKind
.None,
79
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType,
83
TypeParameterConstraintKind
constraints,
91
case
TypeParameterConstraintKind
.None:
94
case
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType:
103
TypeParameterConstraintKind
constraints,
107
switch (constraints &
TypeParameterConstraintKind
.AllReferenceTypeKinds)
109
case
TypeParameterConstraintKind
.None:
110
case
TypeParameterConstraintKind
.ReferenceType:
111
case
TypeParameterConstraintKind
.NullableReferenceType:
112
case
TypeParameterConstraintKind
.NotNullableReferenceType:
119
Debug.Assert((constraints &
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType) == 0 ||
120
(constraints & ~(
TypeParameterConstraintKind
.ObliviousNullabilityIfReferenceType |
TypeParameterConstraintKind
.Constructor |
121
TypeParameterConstraintKind
.Default |
TypeParameterConstraintKind
.PartialMismatch |
122
TypeParameterConstraintKind
.ValueTypeFromConstraintTypes |
TypeParameterConstraintKind
.ReferenceTypeFromConstraintTypes |
123
TypeParameterConstraintKind
.AllowByRefLike)) == 0);
129
public readonly
TypeParameterConstraintKind
Constraints;
163
if ((constraintClause.Constraints &
TypeParameterConstraintKind
.AllValueTypeKinds) != 0)
Symbols\Source\TypeParameterInfo.cs (2)
28
public ImmutableArray<
TypeParameterConstraintKind
> LazyTypeParameterConstraintKinds;
34
LazyTypeParameterConstraintKinds = ImmutableArray<
TypeParameterConstraintKind
>.Empty,
Symbols\Synthesized\Records\SynthesizedRecordOrdinaryMethod.cs (2)
55
public sealed override ImmutableArray<
TypeParameterConstraintKind
> GetTypeParameterConstraintKinds() => 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;