Skip to content

Casts in switch statements are not preserved #3577

Description

@nikitalita

Casts in the switch statements are not preserved, leading to non-compilable code being generated:

Input

public class TestClass
{
    public int _Notification(int what)
    {
        int result = 0;
        switch ((long) what)
        {
            case 1L:
                result = 1;
                break;
            case 2L:
                result = 2;
                break;
        }
        return result;
    }
}

Incorrect Output (no (long) in switch)

public class TestClass
{
	public int _Notification(int what)
	{
		int result = 0;
		switch (what)
		{
		case 1L:
			result = 1;
			break;
		case 2L:
			result = 2;
			break;
		}
		return result;
	}
}

Details

  • Product in use: IlSpyCmd
  • Version in use: current master

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions