Skip to content

String interpolation: new difference in dynamic/static overload resolution #306

@controlflow

Description

@controlflow
using System;

class Foo {
    void M(object[] xs) {
        IFormattable s1 = $"{null}"; // Create("{0}", new object[1])
        IFormattable s2 = $"{xs}";   // Create("{0}", new object[] { xs })

        dynamic nil = null, ys = xs;
        IFormattable d1 = $"{nil}";  // Create("{0}", (object[]) null)
        IFormattable d2 = $"{ys}";   // Create("{0}", (object[]) xs)
    }
}

namespace System.Runtime.CompilerServices {
    public static class FormattableStringFactory {
        public static IFormattable Create(string format, params object[] xs) => null;
    }
}

Can this be solved with current dynamic codegen? Maybe with some flags...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions