internal BaseMethodWrapperSymbol(NamedTypeSymbol containingType, MethodSymbol methodBeingWrapped, CSharpSyntaxNode syntax, string name) : base(containingType, methodBeingWrapped, syntax.SyntaxTree.GetReference(syntax), null, syntax.GetLocation(), name, DeclarationModifiers.Private) { Debug.Assert(containingType.ContainingModule is SourceModuleSymbol); Debug.Assert(ReferenceEquals(methodBeingWrapped, methodBeingWrapped.ConstructedFrom)); Debug.Assert(!methodBeingWrapped.IsStatic); TypeMap typeMap = null; ImmutableArray <TypeParameterSymbol> typeParameters; var substitutedType = methodBeingWrapped.ContainingType as SubstitutedNamedTypeSymbol; typeMap = ((object)substitutedType == null ? TypeMap.Empty : substitutedType.TypeSubstitution); if (!methodBeingWrapped.IsGenericMethod) { typeParameters = ImmutableArray <TypeParameterSymbol> .Empty; } else { typeMap = typeMap.WithAlphaRename(methodBeingWrapped, this, out typeParameters); } AssignTypeMapAndTypeParameters(typeMap, typeParameters); }
private void EnsureMapAndTypeParameters() { if (!_lazyTypeParameters.IsDefault) { return; } ImmutableArray <TypeParameterSymbol> typeParameters; Debug.Assert(ReferenceEquals(_constructedFrom, this)); // We're creating a new unconstructed Method from another; alpha-rename type parameters. var newMap = _inputMap.WithAlphaRename(this.OriginalDefinition, this, out typeParameters); var prevMap = Interlocked.CompareExchange(ref _lazyMap, newMap, null); if (prevMap != null) { // There is a race with another thread who has already set the map // need to ensure that typeParameters, matches the map typeParameters = prevMap.SubstituteTypeParameters(this.OriginalDefinition.TypeParameters); } ImmutableInterlocked.InterlockedCompareExchange(ref _lazyTypeParameters, typeParameters, default(ImmutableArray <TypeParameterSymbol>)); Debug.Assert(_lazyTypeParameters != null); }