Pchp.CodeAnalysis.Symbols.SourceRoutineSymbol.SynthesizeOverloadsWithOptionalParameters C# (CSharp) Method

SynthesizeOverloadsWithOptionalParameters() protected method

Synthesizes method overloads in case there are optional parameters which explicit default value cannot be resolved as a ConstantValue.
foo($a = [], $b = [1, 2, 3]) + foo() => foo([], [1, 2, 3) + foo($a) => foo($a, [1, 2, 3])
protected SynthesizeOverloadsWithOptionalParameters ( PEModuleBuilder module, DiagnosticBag diagnostic ) : void
module PEModuleBuilder
diagnostic DiagnosticBag
return void
        protected void SynthesizeOverloadsWithOptionalParameters(PEModuleBuilder module, DiagnosticBag diagnostic)
        {
            var ps = this.Parameters;
            for (int i = 0; i < ps.Length; i++)
            {
                var p = ps[i] as SourceParameterSymbol;
                if (p != null && p.Initializer != null && p.ExplicitDefaultConstantValue == null)   // => ConstantValue couldn't be resolved for optional parameter
                {
                    // create ghost stub foo(p0, .. pi-1) => foo(p0, .. , pN)
                    CreateGhostOverload(module, diagnostic, i);
                }
            }
        }