fix(csharp): classify interface base types as inherits, not implements#1817
Open
Synvoya wants to merge 1 commit into
Open
fix(csharp): classify interface base types as inherits, not implements#1817Synvoya wants to merge 1 commit into
Synvoya wants to merge 1 commit into
Conversation
A C# `interface`'s base_list holds base interfaces, so extending another interface is interface *inheritance*, not implementation. The base_list emitter classified every entry with the name-based class-vs-interface heuristic (`_csharp_classify_base`), so `interface IDerived : IBase` produced an `implements` edge -- diverging from the Java extractor, which emits `inherits` for `extends_interfaces`. Classify base types as `inherits` when the declaring node is an `interface_declaration`; class/struct/record declarations keep the existing name-based split (first non-interface base = inherits, interfaces = implements). `implements` now means only a class/struct/record realizing an interface, consistent with the rest of the extractors. Adds a regression test covering single- and multi-interface extension plus a class implementer as a negative control.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A C#
interface's base_list holds base interfaces, so extending anotherinterface is interface inheritance, not implementation. The C# base_list
emitter in
_extract_genericclassified every base-list entry with thename-based class-vs-interface heuristic (
_csharp_classify_base), so aninterface extending another interface produced an
implementsedge.This diverges from the Java extractor in the same engine, which emits
inheritsforextends_interfaces. The result is an inconsistent typehierarchy: traversing
inheritsedges misses C# interface hierarchies thatit would capture for Java.
Reproduction (v8 HEAD)
The equivalent Java (
interface IDerived extends IBase) already yieldsIDerived --inherits--> IBase.Fix
When the declaring node is an
interface_declaration, classify each base asinherits(all interface base-list entries are inherited base interfaces).Class/struct/record declarations keep the existing name-based split — the
first non-interface base stays
inherits, interface bases stayimplements— so
implementsnow means only a class/struct/record realizing aninterface, matching the other language extractors.
Base extraction, generic-argument
referencesedges, and theref_token/qualified/ref_qualifiermetadata used by cross-fileresolution are unchanged; only the emitted
relationfor interface-declaredbases changes.
Testing
test_csharp_interface_extends_is_inherits_not_implementscovers single- and multi-interface extension and a class implementer as a
negative control. It fails on
v8HEAD (interface bases land inimplements) and passes with this change.tests/test_languages.py: 315 passed, 13 skipped.test_csharp_type_resolution.py,test_csharp_member_calls.py,test_dotnet.py,test_cross_language_call_resolution.py: 89 passed.