コード例 #1
0
        private static TypeSymbolWithAnnotations SubstituteAllTypeParameters(AbstractTypeMap substitution, TypeSymbolWithAnnotations type)
        {
            if (substitution != null)
            {
                TypeSymbolWithAnnotations previous;
                do
                {
                    previous = type;
                    type     = type.SubstituteType(substitution);
                } while (!type.IsSameAs(previous));
            }

            return(type);
        }
コード例 #2
0
        internal override bool ApplyNullableTransforms(byte defaultTransformFlag, ImmutableArray <byte> transforms, ref int position, out TypeSymbol result)
        {
            TypeSymbolWithAnnotations oldElementType = ElementType;
            TypeSymbolWithAnnotations newElementType;

            if (!oldElementType.ApplyNullableTransforms(defaultTransformFlag, transforms, ref position, out newElementType))
            {
                result = this;
                return(false);
            }

            result = WithElementType(newElementType);
            return(true);
        }
コード例 #3
0
ファイル: NullableTypeDecoder.cs プロジェクト: skynode/roslyn
        /// <summary>
        /// If the type reference has an associated NullableAttribute, this method
        /// returns the type transformed to have IsNullable set to true or false
        /// (but not null) for each reference type in the type.
        /// </summary>
        internal static TypeSymbolWithAnnotations TransformType(
            TypeSymbolWithAnnotations metadataType,
            EntityHandle targetSymbolToken,
            PEModuleSymbol containingModule,
            INonNullTypesContext nonNullTypesContext)
        {
            Debug.Assert(!metadataType.IsNull);

            ImmutableArray <bool> nullableTransformFlags;

            containingModule.Module.HasNullableAttribute(targetSymbolToken, out nullableTransformFlags);

            return(TransformType(metadataType, nullableTransformFlags, nonNullTypesContext));
        }
コード例 #4
0
ファイル: NullableTypeDecoder.cs プロジェクト: skynode/roslyn
        internal static TypeSymbolWithAnnotations TransformType(TypeSymbolWithAnnotations metadataType, ImmutableArray <bool> nullableTransformFlags, INonNullTypesContext nonNullTypesContext)
        {
            int position = 0;
            TypeSymbolWithAnnotations result;

            if (metadataType.ApplyNullableTransforms(nullableTransformFlags, nonNullTypesContext, ref position, out result) &&
                (nullableTransformFlags.IsDefault || position == nullableTransformFlags.Length))
            {
                return(result);
            }

            // No NullableAttribute applied to the target symbol, or flags do not line-up, return unchanged metadataType.
            return(metadataType);
        }
コード例 #5
0
        public SignatureOnlyParameterSymbol(
            TypeSymbolWithAnnotations type,
            ImmutableArray <CustomModifier> refCustomModifiers,
            bool isParams,
            RefKind refKind)
        {
            Debug.Assert((object)type.TypeSymbol != null);
            Debug.Assert(!refCustomModifiers.IsDefault);

            _type = type;
            _refCustomModifiers = refCustomModifiers;
            _isParams           = isParams;
            _refKind            = refKind;
        }
コード例 #6
0
        /// <summary>
        /// If the type reference has an associated NullableAttribute, this method
        /// returns the type transformed to have IsNullable set to true or false
        /// (but not null) for each reference type in the type.
        /// </summary>
        internal static TypeSymbolWithAnnotations TransformType(
            TypeSymbolWithAnnotations metadataType,
            EntityHandle targetSymbolToken,
            PEModuleSymbol containingModule)
        {
            Debug.Assert(!metadataType.IsNull);

            byte defaultTransformFlag;
            ImmutableArray <byte> nullableTransformFlags;

            containingModule.Module.HasNullableAttribute(targetSymbolToken, out defaultTransformFlag, out nullableTransformFlags);

            return(TransformType(metadataType, defaultTransformFlag, nullableTransformFlags));
        }
コード例 #7
0
        private BoundLocal GetBoundPatternMatchingLocal(TypeSymbol type)
        {
            // All synthesized pattern matching locals are associated with the Switch statement syntax node.
            // Their ordinals are zero.
            // EnC local slot variable matching logic find the right slot based on the type of the local.

            if (!localByType.TryGetValue(type, out var localSymbol))
            {
                localSymbol = new SynthesizedLocal(_enclosingSymbol as MethodSymbol, TypeSymbolWithAnnotations.Create(type), SynthesizedLocalKind.SwitchCasePatternMatching, _switchSyntax);
                localByType.Add(type, localSymbol);
            }

            return(new BoundLocal(_switchSyntax, localSymbol, null, type));
        }
コード例 #8
0
        private LambdaCapturedVariable(SynthesizedContainer frame, TypeSymbolWithAnnotations type, string fieldName, bool isThisParameter)
            : base(frame,
                   fieldName,
                   isPublic: true,
                   isReadOnly: false,
                   isStatic: false)
        {
            Debug.Assert(!type.IsNull);

            // lifted fields do not need to have the CompilerGeneratedAttribute attached to it, the closure is already
            // marked as being compiler generated.
            _type   = type;
            _isThis = isThisParameter;
        }
コード例 #9
0
ファイル: EELocalSymbol.cs プロジェクト: lhutyra/stark-roslyn
 public EELocalSymbol(
     MethodSymbol method,
     ImmutableArray <Location> locations,
     string nameOpt,
     int ordinal,
     LocalDeclarationKind declarationKind,
     TypeSymbol type,
     RefKind refKind,
     bool isPinned,
     bool isCompilerGenerated,
     bool canScheduleToStack)
     : this(method, locations, nameOpt, ordinal, declarationKind, TypeSymbolWithAnnotations.Create(type), refKind, isPinned, isCompilerGenerated, canScheduleToStack)
 {
 }
コード例 #10
0
        private TypeSymbolWithAnnotations GetTypeSymbol()
        {
            var diagnostics = DiagnosticBag.GetInstance();

            Binder typeBinder = this.TypeSyntaxBinder;

            bool isVar;
            TypeSymbolWithAnnotations declType;

            if (_typeSyntax == null) // In recursive patterns the type may be omitted.
            {
                isVar    = true;
                declType = default;
            }
            else
            {
                declType = typeBinder.BindTypeOrVarKeyword(_typeSyntax, diagnostics, out isVar);
            }

            if (isVar)
            {
                var inferredType = InferTypeOfVarVariable(diagnostics);

                // If we got a valid result that was not void then use the inferred type
                // else create an error type.
                if (!inferredType.IsNull &&
                    inferredType.SpecialType != SpecialType.System_Void)
                {
                    declType = inferredType;
                }
                else
                {
                    declType = TypeSymbolWithAnnotations.Create(typeBinder.CreateErrorType("var"));
                }
            }

            Debug.Assert(!declType.IsNull);

            //
            // Note that we drop the diagnostics on the floor! That is because this code is invoked mainly in
            // IDE scenarios where we are attempting to use the types of a variable before we have processed
            // the code which causes the variable's type to be inferred. In batch compilation, on the
            // other hand, local variables have their type inferred, if necessary, in the course of binding
            // the statements of a method from top to bottom, and an inferred type is given to a variable
            // before the variable's type is used by the compiler.
            //
            diagnostics.Free();
            return(declType);
        }
コード例 #11
0
        public static ParameterSymbol Create(
            MethodSymbol container,
            TypeSymbolWithAnnotations type,
            int ordinal,
            RefKind refKind,
            string name = "",
            ImmutableArray <CustomModifier> refCustomModifiers = default(ImmutableArray <CustomModifier>))
        {
            if (refCustomModifiers.IsDefaultOrEmpty)
            {
                return(new SynthesizedParameterSymbol(container, type, ordinal, refKind, name));
            }

            return(new SynthesizedParameterSymbolWithCustomModifiers(container, type, ordinal, refKind, name, refCustomModifiers));
        }
コード例 #12
0
 // https://github.com/dotnet/roslyn/issues/29821 external annotations should be removed or fully designed/productized
 internal static TypeSymbolWithAnnotations TransformType(
     TypeSymbolWithAnnotations metadataType,
     EntityHandle targetSymbolToken,
     PEModuleSymbol containingModule,
     ImmutableArray <byte> extraAnnotations)
 {
     if (extraAnnotations.IsDefault)
     {
         return(NullableTypeDecoder.TransformType(metadataType, targetSymbolToken, containingModule));
     }
     else
     {
         return(NullableTypeDecoder.TransformType(metadataType, defaultTransformFlag: 0, extraAnnotations));
     }
 }
コード例 #13
0
 // https://github.com/dotnet/roslyn/issues/29821 external annotations should be removed or fully designed/productized
 internal static TypeSymbolWithAnnotations TransformType(
     TypeSymbolWithAnnotations metadataType,
     EntityHandle targetSymbolToken,
     PEModuleSymbol containingModule,
     ImmutableArray <bool> extraAnnotations)
 {
     if (extraAnnotations.IsDefault)
     {
         return(NullableTypeDecoder.TransformType(metadataType, targetSymbolToken, containingModule));
     }
     else
     {
         return(NullableTypeDecoder.TransformType(metadataType, extraAnnotations).WithNonNullTypesContext(NonNullTypesTrueContext.Instance));
     }
 }
コード例 #14
0
        private void VisitTypeSymbolWithAnnotations(TypeSymbolWithAnnotations type, AbstractSymbolDisplayVisitor visitorOpt = null)
        {
            var visitor    = (SymbolDisplayVisitor)(visitorOpt ?? this.NotFirstVisitor);
            var typeSymbol = type.TypeSymbol;

            if (typeSymbol.TypeKind == TypeKind.Array)
            {
                visitor.VisitArrayType((IArrayTypeSymbol)typeSymbol, typeOpt: type);
            }
            else
            {
                typeSymbol.Accept(visitor);
                AddNullableAnnotations(type);
            }
        }
コード例 #15
0
        internal static ArrayTypeSymbol CreateMDArray(
            TypeSymbolWithAnnotations elementType,
            int rank,
            ImmutableArray <int> sizes,
            ImmutableArray <int> lowerBounds,
            NamedTypeSymbol array)
        {
            // Optimize for most common case - no sizes and all dimensions are zero lower bound.
            if (sizes.IsDefaultOrEmpty && lowerBounds.IsDefault)
            {
                return(new MDArrayNoSizesOrBounds(elementType, rank, array));
            }

            return(new MDArrayWithSizesAndBounds(elementType, rank, sizes, lowerBounds, array));
        }
コード例 #16
0
        Cci.ITypeReference Cci.IFieldReference.GetType(EmitContext context)
        {
            TypeSymbolWithAnnotations oldType = _underlyingField.Type;
            var customModifiers = oldType.CustomModifiers;
            var type            = ((PEModuleBuilder)context.Module).Translate(oldType.TypeSymbol, syntaxNodeOpt: (CSharpSyntaxNode)context.SyntaxNodeOpt, diagnostics: context.Diagnostics);

            if (customModifiers.Length == 0)
            {
                return(type);
            }
            else
            {
                return(new Cci.ModifiedTypeReference(type, customModifiers.As <Cci.ICustomModifier>()));
            }
        }
コード例 #17
0
        Cci.ITypeReference Cci.IArrayTypeReference.GetElementType(EmitContext context)
        {
            PEModuleBuilder moduleBeingBuilt = (PEModuleBuilder)context.Module;

            TypeSymbolWithAnnotations elementType = this.ElementType;
            var type = moduleBeingBuilt.Translate(elementType.TypeSymbol, syntaxNodeOpt: (CSharpSyntaxNode)context.SyntaxNodeOpt, diagnostics: context.Diagnostics);

            if (elementType.CustomModifiers.Length == 0)
            {
                return(type);
            }
            else
            {
                return(new Cci.ModifiedTypeReference(type, elementType.CustomModifiers.As <Cci.ICustomModifier>()));
            }
        }
コード例 #18
0
        internal void SetType(TypeSymbolWithAnnotations newType)
        {
            Debug.Assert(!(newType.TypeSymbol is null));
            TypeSymbol originalType = _type.DefaultType;

            // In the event that we race to set the type of a local, we should
            // always deduce the same type, or deduce that the type is an error.

            Debug.Assert((object)originalType == null ||
                         originalType.IsErrorType() && newType.IsErrorType() ||
                         TypeSymbol.Equals(originalType, newType.TypeSymbol, TypeCompareKind.ConsiderEverything2));

            if ((object)originalType == null)
            {
                _type.InterlockedInitialize(newType);
            }
        }
コード例 #19
0
        public SynthesizedParameterSymbolBase(
            MethodSymbol container,
            TypeSymbolWithAnnotations type,
            int ordinal,
            RefKind refKind,
            string name = "")
        {
            Debug.Assert(!type.IsNull);
            Debug.Assert(name != null);
            Debug.Assert(ordinal >= 0);

            _container = container;
            _type      = type;
            _ordinal   = ordinal;
            _refKind   = refKind;
            _name      = name;
        }
コード例 #20
0
        public static TypeSymbolWithAnnotations CreateExtendedTypeSymbol(CSharpSyntaxNode syntax, TypeSymbolWithAnnotations baseSymbol, TypeAccessModifiers accessModifiers, DiagnosticBag diagnostics)
        {
            if (baseSymbol.Kind == SymbolKind.NamedType)
            {
                return(TypeSymbolWithAnnotations.Create(new ExtendedNamedTypeSymbol(baseSymbol, accessModifiers)));
            }

            if (baseSymbol.Kind == SymbolKind.ArrayType)
            {
                return(TypeSymbolWithAnnotations.Create(new ExtendedArrayTypeSymbol(baseSymbol, (ArrayTypeSymbol)baseSymbol.TypeSymbol, accessModifiers)));
            }

            if (baseSymbol.Kind == SymbolKind.TypeParameter)
            {
                return(TypeSymbolWithAnnotations.Create(new ExtendedTypeParameterSymbol((TypeParameterSymbol)baseSymbol.TypeSymbol, accessModifiers)));
            }
            throw new NotSupportedException($"The syntax `{syntax}` is not supported");
        }
コード例 #21
0
ファイル: TypeMap.cs プロジェクト: stark-lang/stark
        private static SmallDictionary <TypeParameterSymbol, TypeSymbolWithAnnotations> ConstructMapping(ImmutableArray <TypeParameterSymbol> from, ImmutableArray <TypeSymbolWithAnnotations> to)
        {
            var mapping = new SmallDictionary <TypeParameterSymbol, TypeSymbolWithAnnotations>(ReferenceEqualityComparer.Instance);

            Debug.Assert(from.Length == to.Length);

            for (int i = 0; i < from.Length; i++)
            {
                TypeParameterSymbol       tp = from[i];
                TypeSymbolWithAnnotations ta = to[i];
                if (!ta.Is(tp))
                {
                    mapping.Add(tp, ta);
                }
            }

            return(mapping);
        }
コード例 #22
0
ファイル: PEParameterSymbol.cs プロジェクト: skynode/roslyn
            public PEParameterSymbolWithCustomModifiers(
                PEModuleSymbol moduleSymbol,
                Symbol containingSymbol,
                int ordinal,
                bool isByRef,
                ImmutableArray <ModifierInfo <TypeSymbol> > refCustomModifiers,
                TypeSymbolWithAnnotations type,
                ImmutableArray <bool> extraAnnotations,
                ParameterHandle handle,
                out bool isBad) :
                base(moduleSymbol, containingSymbol, ordinal, isByRef, type, extraAnnotations, handle,
                     refCustomModifiers.NullToEmpty().Length + type.CustomModifiers.Length,
                     out isBad)
            {
                _refCustomModifiers = CSharpCustomModifier.Convert(refCustomModifiers);

                Debug.Assert(_refCustomModifiers.IsEmpty || isByRef);
            }
コード例 #23
0
        private static ImmutableArray <MethodSymbol> GetAdditionalNullableAttributeConstructors(
            CSharpCompilation compilation,
            NamedTypeSymbol containingType,
            DiagnosticBag diagnostics)
        {
            var boolType = compilation.GetSpecialType(SpecialType.System_Boolean);

            Binder.ReportUseSiteDiagnostics(boolType, diagnostics, Location.None);
            var boolArray = TypeSymbolWithAnnotations.Create(
                ArrayTypeSymbol.CreateSZArray(
                    boolType.ContainingAssembly,
                    TypeSymbolWithAnnotations.Create(boolType)));

            return(ImmutableArray.Create <MethodSymbol>(
                       new SynthesizedEmbeddedAttributeConstructorSymbol(
                           containingType,
                           m => ImmutableArray.Create(SynthesizedParameterSymbol.Create(m, boolArray, 0, RefKind.None)))));
        }
コード例 #24
0
            protected override TypeSymbolWithAnnotations InferTypeOfVarVariable(DiagnosticBag diagnostics)
            {
                switch (_nodeToBind.Kind())
                {
                case SyntaxKind.ThisConstructorInitializer:
                case SyntaxKind.BaseConstructorInitializer:
                    var initializer = (ConstructorInitializerSyntax)_nodeToBind;
                    _nodeBinder.BindConstructorInitializer(initializer, diagnostics);
                    break;

                case SyntaxKind.ArgumentList:
                    var invocation = (ConstructorInitializerSyntax)_nodeToBind.Parent;
                    _nodeBinder.BindConstructorInitializer(invocation, diagnostics);
                    break;

                case SyntaxKind.CasePatternSwitchLabel:
                    _nodeBinder.BindPatternSwitchLabelForInference((CasePatternSwitchLabelSyntax)_nodeToBind, diagnostics);
                    break;

                //case SyntaxKind.VariableDeclaration:
                //    // This occurs, for example, in
                //    // int x, y[out var Z, 1 is int I];
                //    // for (int x, y[out var Z, 1 is int I]; ;) {}
                //    _nodeBinder.BindDeclaratorArguments((VariableDeclarationSyntax)_nodeToBind, diagnostics);
                //    break;
                case SyntaxKind.SwitchExpressionArm:
                    var arm       = (SwitchExpressionArmSyntax)_nodeToBind;
                    var armBinder = (SwitchExpressionArmBinder)_nodeBinder;
                    armBinder.BindSwitchExpressionArm(arm, diagnostics);
                    break;

                default:
                    _nodeBinder.BindExpression((ExpressionSyntax)_nodeToBind, diagnostics);
                    break;
                }

                if (this._type.IsNull)
                {
                    Debug.Assert(this.DeclarationKind == LocalDeclarationKind.DeclarationExpressionVariable);
                    SetType(TypeSymbolWithAnnotations.Create(_nodeBinder.CreateErrorType("var")));
                }

                return(_type.ToType());
            }
コード例 #25
0
        private ArrayTypeSymbol SubstituteArrayType(ArrayTypeSymbol t)
        {
            var oldElement = t.ElementType;
            TypeSymbolWithAnnotations element = oldElement.SubstituteTypeWithTupleUnification(this);

            if (element.IsSameAs(oldElement))
            {
                return(t);
            }

            if (t.IsSZArray)
            {
                ImmutableArray <NamedTypeSymbol> interfaces = t.InterfacesNoUseSiteDiagnostics();
                Debug.Assert(0 <= interfaces.Length && interfaces.Length <= 2);

                if (interfaces.Length == 1)
                {
                    Debug.Assert(interfaces[0] is NamedTypeSymbol); // IList<T>
                    interfaces = ImmutableArray.Create <NamedTypeSymbol>(SubstituteNamedType(interfaces[0]));
                }
                else if (interfaces.Length == 2)
                {
                    Debug.Assert(interfaces[0] is NamedTypeSymbol); // IList<T>
                    interfaces = ImmutableArray.Create <NamedTypeSymbol>(SubstituteNamedType(interfaces[0]), SubstituteNamedType(interfaces[1]));
                }
                else if (interfaces.Length != 0)
                {
                    throw ExceptionUtilities.Unreachable;
                }

                return(ArrayTypeSymbol.CreateSZArray(
                           element,
                           t.BaseTypeNoUseSiteDiagnostics,
                           interfaces));
            }

            return(ArrayTypeSymbol.CreateMDArray(
                       element,
                       t.Rank,
                       t.Sizes,
                       t.LowerBounds,
                       t.BaseTypeNoUseSiteDiagnostics));
        }
コード例 #26
0
        private TypeSymbolWithAnnotations ComputeReturnType(DiagnosticBag diagnostics)
        {
            if (this.MethodKind == MethodKind.PropertyGet)
            {
                var type = _property.Type;
                if (!ContainingType.IsInterfaceType() && type.TypeSymbol.IsStatic)
                {
                    // '{0}': static types cannot be used as return types
                    diagnostics.Add(ErrorCode.ERR_ReturnTypeIsStaticClass, this.locations[0], type.TypeSymbol);
                }

                return(type);
            }
            else
            {
                var binder = GetBinder();
                return(TypeSymbolWithAnnotations.Create(binder.GetSpecialType(SpecialType.System_Void, diagnostics, this.GetSyntax())));
            }
        }
コード例 #27
0
        internal SynthesizedSubmissionConstructor(NamedTypeSymbol containingType, DiagnosticBag diagnostics)
            : base(containingType)
        {
            Debug.Assert(containingType.TypeKind == TypeKind.Submission);
            Debug.Assert(diagnostics != null);

            var compilation = containingType.DeclaringCompilation;

            var submissionArrayType = compilation.CreateArrayTypeSymbol(compilation.GetSpecialType(SpecialType.System_Object));
            var useSiteError        = submissionArrayType.GetUseSiteDiagnostic();

            if (useSiteError != null)
            {
                diagnostics.Add(useSiteError, NoLocation.Singleton);
            }

            _parameters = ImmutableArray.Create <ParameterSymbol>(
                SynthesizedParameterSymbol.Create(this, TypeSymbolWithAnnotations.Create(submissionArrayType), 0, RefKind.None, "submissionArray"));
        }
コード例 #28
0
        /// <remarks>
        /// Out params are updated by assignment.  If you require thread-safety, pass temps and then
        /// CompareExchange them back into shared memory.
        /// </remarks>
        internal static void CopyMethodCustomModifiers(
            MethodSymbol sourceMethod,
            MethodSymbol destinationMethod,
            out TypeSymbolWithAnnotations returnType,
            out ImmutableArray <CustomModifier> customModifiers,
            out ImmutableArray <ParameterSymbol> parameters,
            bool alsoCopyParamsModifier) // Last since always named.
        {
            Debug.Assert((object)sourceMethod != null);

            // Assert: none of the method's type parameters have been substituted
            Debug.Assert((object)sourceMethod == sourceMethod.ConstructedFrom);

            // For the most part, we will copy custom modifiers by copying types.
            // The only time when this fails is when the type refers to a type parameter
            // owned by the overridden method.  We need to replace all such references
            // with (equivalent) type parameters owned by this method.  We know that
            // we can perform this mapping positionally, because the method signatures
            // have already been compared.
            MethodSymbol constructedSourceMethod = sourceMethod.ConstructIfGeneric(destinationMethod.TypeArguments);

            customModifiers =
                destinationMethod.RefKind != RefKind.None ? constructedSourceMethod.RefCustomModifiers : ImmutableArray <CustomModifier> .Empty;

            parameters = CopyParameterCustomModifiers(constructedSourceMethod.Parameters, destinationMethod.Parameters, alsoCopyParamsModifier);

            returnType = destinationMethod.ReturnType; // Default value - in case we don't copy the custom modifiers.
            TypeSymbol returnTypeSymbol = returnType.TypeSymbol;

            var sourceMethodReturnType = constructedSourceMethod.ReturnType;

            // We do an extra check before copying the return type to handle the case where the overriding
            // method (incorrectly) has a different return type than the overridden method.  In such cases,
            // we want to retain the original (incorrect) return type to avoid hiding the return type
            // given in source.
            TypeSymbol returnTypeWithCustomModifiers = sourceMethodReturnType.TypeSymbol;

            if (returnTypeSymbol.Equals(returnTypeWithCustomModifiers, TypeCompareKind.AllIgnoreOptions))
            {
                returnType = returnType.WithTypeAndModifiers(CopyTypeCustomModifiers(returnTypeWithCustomModifiers, returnTypeSymbol, destinationMethod.ContainingAssembly),
                                                             sourceMethodReturnType.CustomModifiers);
            }
        }
コード例 #29
0
 public SignatureOnlyPropertySymbol(
     string name,
     TypeSymbol containingType,
     ImmutableArray <ParameterSymbol> parameters,
     RefKind refKind,
     TypeSymbolWithAnnotations type,
     ImmutableArray <CustomModifier> refCustomModifiers,
     bool isStatic,
     ImmutableArray <PropertySymbol> explicitInterfaceImplementations)
 {
     _refKind            = refKind;
     _type               = type;
     _refCustomModifiers = refCustomModifiers;
     _isStatic           = isStatic;
     _parameters         = parameters;
     _explicitInterfaceImplementations = explicitInterfaceImplementations.NullToEmpty();
     _containingType = containingType;
     _name           = name;
 }
コード例 #30
0
        internal static TypeSymbolWithAnnotations TransformType(TypeSymbolWithAnnotations metadataType, byte defaultTransformFlag, ImmutableArray <byte> nullableTransformFlags)
        {
            if (nullableTransformFlags.IsDefault && defaultTransformFlag == 0)
            {
                return(metadataType);
            }

            int position = 0;
            TypeSymbolWithAnnotations result;

            if (metadataType.ApplyNullableTransforms(defaultTransformFlag, nullableTransformFlags, ref position, out result) &&
                (nullableTransformFlags.IsDefault || position == nullableTransformFlags.Length))
            {
                return(result);
            }

            // No NullableAttribute applied to the target symbol, or flags do not line-up, return unchanged metadataType.
            return(metadataType);
        }