コード例 #1
0
        private readonly bool _cannotUse; // With LanguageVersion 7, we will produce named elements that should not be used

        public TupleVirtualElementFieldSymbol(
            NamedTypeSymbol container,
            FieldSymbol underlyingField,
            string name,
            int tupleElementIndex,
            ImmutableArray <Location> locations,
            bool cannotUse,
            bool isImplicitlyDeclared,
            FieldSymbol?correspondingDefaultFieldOpt
            )
            : base(
                container,
                underlyingField,
                tupleElementIndex,
                locations,
                isImplicitlyDeclared,
                correspondingDefaultFieldOpt
                )
        {
            // The underlying field for 'Hanna' (an 8-th named element) in a long tuple is Item1. The corresponding field is Item8.

            Debug.Assert(container.IsTupleType);
            Debug.Assert(underlyingField.ContainingType.IsTupleType);
            Debug.Assert(name != null);
            Debug.Assert(
                name != underlyingField.Name ||
                !container.Equals(
                    underlyingField.ContainingType,
                    TypeCompareKind.IgnoreDynamicAndTupleNames
                    ),
                "fields that map directly to underlying should not be represented by "
                + nameof(TupleVirtualElementFieldSymbol)
                );
            Debug.Assert(
                (correspondingDefaultFieldOpt is null)
                == (NamedTypeSymbol.TupleMemberName(tupleElementIndex + 1) == name)
                );
            Debug.Assert(!(correspondingDefaultFieldOpt is TupleErrorFieldSymbol));

            _name      = name;
            _cannotUse = cannotUse;
        }