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

[Patterns][records] Instanceof with record deconstruction patterns should never be flagged as unnecessary #1999

Closed
srikanth-sankaran opened this issue Feb 9, 2024 · 0 comments · Fixed by #2011
Assignees
Milestone

Comments

@srikanth-sankaran
Copy link
Contributor

interface I {
}

final class A implements I {
}

final class B implements I {
}

record R(I x, I y) {
}

public class X {
	public static boolean foo(R r) {
		if (r instanceof R(A a1, A a2))  // wrong warning here: The expression of type R is already an instance of type R 
			return true;
		return false;
	}

	public static void main(String argv[]) {
		System.out.println(X.foo(new R(new A(), new A())));
		System.out.println(X.foo(new R(new A(), new B())));
	}
}

@srikanth-sankaran srikanth-sankaran self-assigned this Feb 9, 2024
@srikanth-sankaran srikanth-sankaran changed the title [Patterns][records] Wrong warning "The expression of type R is already an instance of type R" with deconstruction patterns [Patterns][records] Instanceof with record deconstruction patterns should never be flagged as unnecessary Feb 16, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Feb 17, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Feb 18, 2024
@srikanth-sankaran srikanth-sankaran added this to the 4.32 M1 milestone Feb 18, 2024
@mpalat mpalat modified the milestones: 4.32 M1, MilestoneNxt Mar 1, 2024
srikanth-sankaran added a commit to srikanth-sankaran/eclipse.jdt.core that referenced this issue Mar 5, 2024
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

Successfully merging a pull request may close this issue.

2 participants