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

Can't extract method on case expression in match/case clause. #9105

Closed
CyrusNajmabadi opened this issue Feb 23, 2016 · 3 comments
Closed

Can't extract method on case expression in match/case clause. #9105

CyrusNajmabadi opened this issue Feb 23, 2016 · 3 comments

Comments

@CyrusNajmabadi
Copy link
Member

 p match (
            case Student s when s.Gpa > 3.5 :
                $"Honor Student { s.Name } ({ s.Gpa })")

Trying to extract out the string literal extracts out the entire match/case expression into a new method.

@gafter
Copy link
Member

gafter commented Feb 23, 2016

The match expression is not in scope for the current punch-through.

@gafter gafter added this to the 2.0 (RC) milestone Feb 25, 2016
@gafter gafter self-assigned this Apr 25, 2016
@gafter gafter modified the milestones: 3.0, 2.0 (RC) Jun 26, 2016
@gafter gafter removed their assignment May 29, 2018
@gafter
Copy link
Member

gafter commented May 29, 2018

This issue is verified reproducible in the current prototype:

class Program5
{
    string M(Person p)
    {
        return p switch {
            Student s when s.Gpa > 3.5 => $"Honor Student { s.Name } ({ s.Gpa })",
            _ => throw null
        };
    }
}

class Person
{
}
class Student : Person
{
    public double Gpa;
    public string Name;
}

@gafter gafter modified the milestones: 16.0, 16.1 Feb 26, 2019
@jcouv jcouv modified the milestones: 16.1, 16.2 Apr 23, 2019
@jcouv jcouv modified the milestones: 16.2, 16.3 Jun 19, 2019
@jcouv jcouv modified the milestones: 16.3, Compiler.Next Jul 11, 2019
@CyrusNajmabadi
Copy link
Member Author

This works fine now. Closing out:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants