protected override void MethodChecks(DiagnosticBag diagnostics) { // These values may not be final, but we need to have something set here in the // event that we need to find the overridden accessor. _lazyParameters = ComputeParameters(diagnostics); _lazyReturnType = ComputeReturnType(diagnostics); _lazyReturnTypeCustomModifiers = ImmutableArray <CustomModifier> .Empty; if (_explicitInterfaceImplementations.Length > 0) { Debug.Assert(_explicitInterfaceImplementations.Length == 1); MethodSymbol implementedMethod = _explicitInterfaceImplementations[0]; CustomModifierUtils.CopyMethodCustomModifiers(implementedMethod, this, out _lazyReturnType, out _lazyReturnTypeCustomModifiers, out _lazyParameters, alsoCopyParamsModifier: false); } else if (this.IsOverride) { // This will cause another call to SourceMethodSymbol.LazyMethodChecks, // but that method already handles reentrancy for exactly this case. MethodSymbol overriddenMethod = this.OverriddenMethod; if ((object)overriddenMethod != null) { CustomModifierUtils.CopyMethodCustomModifiers(overriddenMethod, this, out _lazyReturnType, out _lazyReturnTypeCustomModifiers, out _lazyParameters, alsoCopyParamsModifier: true); } } else if (_lazyReturnType.SpecialType != SpecialType.System_Void) { PropertySymbol associatedProperty = _property; _lazyReturnType = CustomModifierUtils.CopyTypeCustomModifiers(associatedProperty.Type, _lazyReturnType, RefKind.None, this.ContainingAssembly); _lazyReturnTypeCustomModifiers = associatedProperty.TypeCustomModifiers; } }
internal SourceParameterSymbol WithCustomModifiersAndParamsCore(TypeSymbol newType, ImmutableArray <CustomModifier> newCustomModifiers, ImmutableArray <CustomModifier> newRefCustomModifiers, bool newIsParams) { newType = CustomModifierUtils.CopyTypeCustomModifiers(newType, this.Type, this.ContainingAssembly); TypeWithAnnotations newTypeWithModifiers = this.TypeWithAnnotations.WithTypeAndModifiers(newType, newCustomModifiers); if (newRefCustomModifiers.IsEmpty) { return(new SourceComplexParameterSymbol( this.ContainingSymbol, this.Ordinal, newTypeWithModifiers, _refKind, _name, _locations, this.SyntaxReference, newIsParams, this.IsExtensionMethodThis)); } // Local functions should never have custom modifiers Debug.Assert(!(ContainingSymbol is LocalFunctionSymbol)); return(new SourceComplexParameterSymbolWithCustomModifiersPrecedingByRef( this.ContainingSymbol, this.Ordinal, newTypeWithModifiers, _refKind, newRefCustomModifiers, _name, _locations, this.SyntaxReference, newIsParams, this.IsExtensionMethodThis)); }
internal SourceParameterSymbol WithCustomModifiersAndParamsCore(TypeSymbol newType, ImmutableArray <CustomModifier> newCustomModifiers, ushort countOfCustomModifiersPrecedingByRef, bool newIsParams) { newType = CustomModifierUtils.CopyTypeCustomModifiers(newType, this.Type, _refKind, this.ContainingAssembly); if (newCustomModifiers.IsDefaultOrEmpty) { return(new SourceComplexParameterSymbol( this.ContainingSymbol, this.Ordinal, newType, _refKind, _name, _locations, this.SyntaxReference, this.ExplicitDefaultConstantValue, newIsParams, this.IsExtensionMethodThis)); } return(new SourceComplexParameterSymbolWithCustomModifiers( this.ContainingSymbol, this.Ordinal, newType, _refKind, newCustomModifiers, countOfCustomModifiersPrecedingByRef, _name, _locations, this.SyntaxReference, this.ExplicitDefaultConstantValue, newIsParams, this.IsExtensionMethodThis)); }
protected static void CopyEventCustomModifiers(EventSymbol eventWithCustomModifiers, ref TypeSymbol type, AssemblySymbol containingAssembly) { Debug.Assert((object)eventWithCustomModifiers != null); TypeSymbol overriddenEventType = eventWithCustomModifiers.Type; // We do an extra check before copying the type to handle the case where the overriding // event (incorrectly) has a different type than the overridden event. In such cases, // we want to retain the original (incorrect) type to avoid hiding the type given in source. if (type.Equals(overriddenEventType, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreDynamic)) { type = CustomModifierUtils.CopyTypeCustomModifiers(overriddenEventType, type, containingAssembly); } }
protected override void MethodChecks(DiagnosticBag diagnostics) { // These values may not be final, but we need to have something set here in the // event that we need to find the overridden accessor. _lazyParameters = ComputeParameters(diagnostics); _lazyReturnType = ComputeReturnType(diagnostics); _lazyCustomModifiers = CustomModifiersTuple.Empty; if (_explicitInterfaceImplementations.Length > 0) { Debug.Assert(_explicitInterfaceImplementations.Length == 1); MethodSymbol implementedMethod = _explicitInterfaceImplementations[0]; CustomModifierUtils.CopyMethodCustomModifiers(implementedMethod, this, out _lazyReturnType, out _lazyCustomModifiers, out _lazyParameters, alsoCopyParamsModifier: false); } else if (this.IsOverride) { // This will cause another call to SourceMethodSymbol.LazyMethodChecks, // but that method already handles reentrancy for exactly this case. MethodSymbol overriddenMethod = this.OverriddenMethod; if ((object)overriddenMethod != null) { CustomModifierUtils.CopyMethodCustomModifiers(overriddenMethod, this, out _lazyReturnType, out _lazyCustomModifiers, out _lazyParameters, alsoCopyParamsModifier: true); } #if XSHARP /*if (this.IsVirtual)*/ { if ((object)overriddenMethod != null) { flags = new Flags(flags.MethodKind, flags.DeclarationModifiers & ~DeclarationModifiers.Virtual, flags.ReturnsVoid, flags.IsExtensionMethod, flags.IsMetadataVirtual(true)); } else { flags = new Flags(flags.MethodKind, flags.DeclarationModifiers & ~DeclarationModifiers.Override, flags.ReturnsVoid, flags.IsExtensionMethod, flags.IsMetadataVirtual(true)); } } #endif } else if (_lazyReturnType.SpecialType != SpecialType.System_Void) { PropertySymbol associatedProperty = _property; _lazyReturnType = CustomModifierUtils.CopyTypeCustomModifiers(associatedProperty.Type, _lazyReturnType, this.ContainingAssembly); _lazyCustomModifiers = CustomModifiersTuple.Create(associatedProperty.TypeCustomModifiers, associatedProperty.RefCustomModifiers); } }
protected static void CopyEventCustomModifiers(EventSymbol eventWithCustomModifiers, ref TypeSymbolWithAnnotations type, AssemblySymbol containingAssembly, Symbol nonNullTypesContext) { Debug.Assert((object)eventWithCustomModifiers != null); Debug.Assert(nonNullTypesContext != null); TypeSymbol overriddenEventType = eventWithCustomModifiers.Type.TypeSymbol; // We do an extra check before copying the type to handle the case where the overriding // event (incorrectly) has a different type than the overridden event. In such cases, // we want to retain the original (incorrect) type to avoid hiding the type given in source. if (type.TypeSymbol.Equals(overriddenEventType, TypeCompareKind.IgnoreCustomModifiersAndArraySizesAndLowerBounds | TypeCompareKind.IgnoreNullableModifiersForReferenceTypes | TypeCompareKind.IgnoreDynamic)) { type = type.WithTypeAndModifiers(CustomModifierUtils.CopyTypeCustomModifiers(overriddenEventType, type.TypeSymbol, containingAssembly, nonNullTypesContext), eventWithCustomModifiers.Type.CustomModifiers); } }
internal SourceParameterSymbol WithCustomModifiersAndParamsCore(TypeSymbol newType, ImmutableArray <CustomModifier> newCustomModifiers, bool hasByRefBeforeCustomModifiers, bool newIsParams) { newType = CustomModifierUtils.CopyTypeCustomModifiers(newType, this.Type, this.refKind, this.ContainingAssembly); return(new SourceComplexParameterSymbol( this.ContainingSymbol, this.Ordinal, newType, this.refKind, newCustomModifiers, hasByRefBeforeCustomModifiers, this.name, this.locations, this.SyntaxReference, this.ExplicitDefaultConstantValue, newIsParams, this.IsExtensionMethodThis)); }