Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ref returns/locals: Extract Method does not generate ref-returning methods #8439

Closed
dpoeschl opened this issue Feb 6, 2016 · 1 comment · Fixed by #70931
Closed

Ref returns/locals: Extract Method does not generate ref-returning methods #8439

dpoeschl opened this issue Feb 6, 2016 · 1 comment · Fixed by #70931

Comments

@dpoeschl
Copy link
Contributor

dpoeschl commented Feb 6, 2016

Extract method ref M() in:

class Program
{
    public ref int M()
    {
        return ref M(); // extract method on the returned expression
    }
}

Expected: The returned value should still be marked ref and the generated method should be marked ref

class Program
{
    public ref int M()
    {
        return ref NewMethod();
    }

    private ref int NewMethod()
    {
        return ref M(); // Extract method on this
    }
}

Actual: Neither location is marked ref, causing two errors.

class Program
{
    public ref int M()
    {
        return NewMethod();      // CS 8895
    }

    private int NewMethod()
    {
        return ref M(); // Extract method on this         // CS 8894
    }
}
@DustinCampbell
Copy link
Member

@jaredpar - here's another for the compiler.

@dpoeschl dpoeschl added the Feature - Ref Locals and Returns Ref Locals and Returns label Feb 11, 2016
@VSadov VSadov modified the milestone: 2.0 (Preview 1) Jun 11, 2016
@gafter gafter modified the milestones: 2.0 (Preview 1), 2.0 (RC) Jun 20, 2016
@jaredpar jaredpar modified the milestones: 2.0 (RC), 2.0 (RTM) Jul 18, 2016
@jaredpar jaredpar modified the milestones: 2.1, 2.0 (RTM) Jan 12, 2017
@jaredpar jaredpar modified the milestones: 15.3, 15.1 Mar 9, 2017
@jaredpar jaredpar modified the milestones: 15.3, 15.later Apr 21, 2017
@jaredpar jaredpar modified the milestones: 15.6, 16.0 Jan 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants