Skip to content

Address PROTOTYPE comments for TypeSymbolExtensions.IsUnconstrainedTypeParameter method #30056

@AlekseyTs

Description

@AlekseyTs
        // PROTOTYPE(NullableReferenceTypes): Should probably rename this method to have more specific name.
        //                                    At the moment it is used only for Nullable Reference Types feature and
        //                                    its implementation is specialized for this feature.
        public static bool IsUnconstrainedTypeParameter(this TypeSymbol type)
        {
            if (type.TypeKind != TypeKind.TypeParameter)
            {
                return false;
            }
            var typeParameter = (TypeParameterSymbol)type;
            // PROTOTYPE(NullableReferenceTypes): Test `where T : unmanaged`. See
            // UninitializedNonNullableFieldTests.TypeParameterConstraints for instance.
            return !typeParameter.IsValueType && !(typeParameter.IsReferenceType && typeParameter.IsNotNullableIfReferenceType == true);
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions