mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 22:02:45 +01:00
Outside of `match_first` this adds diagnostics for invalid non-final and final `impl` declarations in line with those being proposed in https://github.com/carbon-language/carbon-lang/pull/5337. - Two non-final `impl`s with the exact same type structure is invalid. - A `final impl` that matches the self/constraint of another `impl` as a query would always be preferred, making the second one invalid. - Two `final impl`s that overlap (have compatible type structures) in different files is invalid. - Two `final impl`s that overlap (have compatible type structures) in the same file is invalid outside of `match_first`. - A `final impl` in a different file from its root self type and interface is invalid. We add tests for all these scenarios as well as correct scenarios. The "compatible" test for two type structures was being done symmetrically, which is incorrect. We want it to test that a query type structure is the same _or more specific_ in a compatible way with an impl's type structure. This is corrected in the implementation, and the diagnostics now have to test both directions to get the desired output, as expected. --------- Co-authored-by: josh11b <15258583+josh11b@users.noreply.github.com>