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

[20] Switch statement with record pattern illegally reported as non-exhaustive #1224

Closed
jarthana opened this issue Jul 11, 2023 · 1 comment
Assignees

Comments

@jarthana
Copy link
Member

The switch in the following code is rejected by ECJ as not exhaustive:

interface I {}
class Class implements I {}
record Record(I s) {}
public class X1 {
    @SuppressWarnings("preview")
	public void foo(Record exp) {
        switch (exp) {
            case Record(Class s) -> {break;}
        }
    }
}

This is because, as per RecordPattern#isTotalForType() , it is considered to be always false. This method needs consider the record pattern's type as well as the nested patterns' types.

@jarthana jarthana self-assigned this Jul 11, 2023
@jarthana
Copy link
Member Author

Since this is still a preview feature in 20 and a standard feature in 21, I would rather we fix this for 21 directly.

Copying @mpalat

jarthana added a commit to jarthana/eclipse.jdt.core that referenced this issue Jul 12, 2023
jarthana added a commit to jarthana/eclipse.jdt.core that referenced this issue Jul 12, 2023
jarthana added a commit to jarthana/eclipse.jdt.core that referenced this issue Jul 14, 2023
jarthana added a commit to jarthana/eclipse.jdt.core that referenced this issue Jul 14, 2023
jarthana added a commit to jarthana/eclipse.jdt.core that referenced this issue Jul 18, 2023
jarthana added a commit to jarthana/eclipse.jdt.core that referenced this issue Jul 18, 2023
jarthana added a commit that referenced this issue Jul 18, 2023
…xhaustive (#1228)

Fixed issue  #1224

Now, a total record pattern, which from now on called as a pattern that covers the expression type, can be mixed with an optional default case. The absence of such default should now be allowed.
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
…xhaustive (eclipse-jdt#1228)

Fixed issue  eclipse-jdt#1224

Now, a total record pattern, which from now on called as a pattern that covers the expression type, can be mixed with an optional default case. The absence of such default should now be allowed.
datho7561 added a commit to datho7561/eclipse.jdt.core that referenced this issue Feb 6, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
datho7561 added a commit to datho7561/eclipse.jdt.core that referenced this issue Feb 7, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
mickaelistria pushed a commit to mickaelistria/eclipse.jdt.core that referenced this issue Feb 7, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Feb 7, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Feb 7, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
mickaelistria pushed a commit to mickaelistria/eclipse.jdt.core that referenced this issue Feb 10, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
mickaelistria pushed a commit to mickaelistria/eclipse.jdt.core that referenced this issue Feb 10, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Feb 13, 2025
Fixes eclipse-jdt#1224

Signed-off-by: David Thompson <davthomp@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant