private void ComputeParameters() { if (_lazyParameters != null) { return; } SyntaxToken arglistToken; var diagnostics = DiagnosticBag.GetInstance(); var parameters = ParameterHelpers.MakeParameters( _binder, this, _syntax.ParameterList, arglistToken: out arglistToken, allowRefOrOut: true, allowThis: true, addRefReadOnlyModifier: false, diagnostics: diagnostics); ParameterHelpers.EnsureIsReadOnlyAttributeExists(parameters, diagnostics, modifyCompilationForRefReadOnly: false); var isVararg = arglistToken.Kind() == SyntaxKind.ArgListKeyword; if (isVararg) { diagnostics.Add(ErrorCode.ERR_IllegalVarArgs, arglistToken.GetLocation()); } if (IsAsync) { SourceOrdinaryMethodSymbol.ReportAsyncParameterErrors(parameters, diagnostics, this.Locations[0]); } lock (_declarationDiagnostics) { if (_lazyParameters != null) { diagnostics.Free(); return; } _declarationDiagnostics.AddRangeAndFree(diagnostics); _lazyIsVarArg = isVararg; _lazyParameters = parameters; } }
/// <summary> /// Gets the syntax list of custom attributes that declares attributes for this parameter symbol. /// </summary> internal virtual OneOrMany <SyntaxList <AttributeListSyntax> > GetAttributeDeclarations() { // C# spec: // The attributes on the parameters of the resulting method declaration // are the combined attributes of the corresponding parameters of the defining // and the implementing partial method declaration in unspecified order. // Duplicates are not removed. SyntaxList <AttributeListSyntax> attributes = AttributeDeclarationList; var sourceMethod = this.ContainingSymbol as SourceOrdinaryMethodSymbol; if ((object)sourceMethod == null) { return(OneOrMany.Create(attributes)); } SyntaxList <AttributeListSyntax> otherAttributes; // if this is a definition get the implementation and vice versa SourceOrdinaryMethodSymbol otherPart = sourceMethod.OtherPartOfPartial; if ((object)otherPart != null) { otherAttributes = ((SourceParameterSymbol)otherPart.Parameters[this.Ordinal]).AttributeDeclarationList; } else { otherAttributes = default(SyntaxList <AttributeListSyntax>); } if (attributes.Equals(default(SyntaxList <AttributeListSyntax>))) { return(OneOrMany.Create(otherAttributes)); } else if (otherAttributes.Equals(default(SyntaxList <AttributeListSyntax>))) { return(OneOrMany.Create(attributes)); } return(OneOrMany.Create(ImmutableArray.Create(attributes, otherAttributes))); }
/// <summary> /// Returns true if the two partial methods have the same constraints. /// </summary> private static bool HaveSameConstraints(SourceOrdinaryMethodSymbol part1, SourceOrdinaryMethodSymbol part2) { Debug.Assert(!ReferenceEquals(part1, part2)); Debug.Assert(part1.Arity == part2.Arity); var typeParameters1 = part1.TypeParameters; int arity = typeParameters1.Length; if (arity == 0) { return(true); } var typeParameters2 = part2.TypeParameters; var indexedTypeParameters = IndexedTypeParameterSymbol.Take(arity); var typeMap1 = new TypeMap(typeParameters1, indexedTypeParameters, allowAlpha: true); var typeMap2 = new TypeMap(typeParameters2, indexedTypeParameters, allowAlpha: true); return(MemberSignatureComparer.HaveSameConstraints(typeParameters1, typeMap1, typeParameters2, typeMap2)); }
public ExplicitInterfaceMethodTypeParameterMap(SourceOrdinaryMethodSymbol implementationMethod) : base(implementationMethod) { Debug.Assert(implementationMethod.IsExplicitInterfaceImplementation); }
public OverriddenMethodTypeParameterMap(SourceOrdinaryMethodSymbol overridingMethod) : base(overridingMethod) { Debug.Assert(overridingMethod.IsOverride); }
protected abstract MethodSymbol GetOverriddenMethod(SourceOrdinaryMethodSymbol overridingMethod);
protected OverriddenMethodTypeParameterMapBase(SourceOrdinaryMethodSymbol overridingMethod) { _overridingMethod = overridingMethod; }
internal static void InitializePartialMethodParts(SourceOrdinaryMethodSymbol definition, SourceOrdinaryMethodSymbol implementation) { Debug.Assert(definition.IsPartialDefinition); Debug.Assert(implementation.IsPartialImplementation); Debug.Assert((object)definition._otherPartOfPartial == null); Debug.Assert((object)implementation._otherPartOfPartial == null); definition._otherPartOfPartial = implementation; implementation._otherPartOfPartial = definition; }
/// <summary> /// Report differences between the defining and implementing /// parts of a partial method. Diagnostics are reported on the /// implementing part, matching Dev10 behavior. /// </summary> private static void PartialMethodChecks(SourceOrdinaryMethodSymbol definition, SourceOrdinaryMethodSymbol implementation, DiagnosticBag diagnostics) { Debug.Assert(!ReferenceEquals(definition, implementation)); if (definition.IsStatic != implementation.IsStatic) { diagnostics.Add(ErrorCode.ERR_PartialMethodStaticDifference, implementation.Locations[0]); } if (definition.IsExtensionMethod != implementation.IsExtensionMethod) { diagnostics.Add(ErrorCode.ERR_PartialMethodExtensionDifference, implementation.Locations[0]); } if (definition.IsUnsafe != implementation.IsUnsafe && definition.CompilationAllowsUnsafe()) // Don't cascade. { diagnostics.Add(ErrorCode.ERR_PartialMethodUnsafeDifference, implementation.Locations[0]); } if (definition.IsParams() != implementation.IsParams()) { diagnostics.Add(ErrorCode.ERR_PartialMethodParamsDifference, implementation.Locations[0]); } if (!HaveSameConstraints(definition, implementation)) { diagnostics.Add(ErrorCode.ERR_PartialMethodInconsistentConstraints, implementation.Locations[0], implementation); } }