sdk icon indicating copy to clipboard operation
sdk copied to clipboard

CONFLICTING_GENERIC_INTERFACES needs context messages

Open bwilkerson opened this issue 1 year ago • 0 comments

The diagnostic CompileTimeErrorCode.CONFLICTING_GENERIC_INTERFACES can be confusing if the two conflicting interfaces are not directly visible at the point at which it's reported. For example, consider

class I<T> {}
class A implements I<int> {}
class B implements I<String> {}
class C extends A implements B {}

where we report the diagnostic at C.

One way to solve the problem is to add at least two context messages, one for each of the interfaces, pointing the user to where the interfaces are specified in the code (the types I<int> and I<String>). Something along the lines of "The type '{0}' comes from here."

That won't completely take case of the case where there's a path of declarations to follow in order to get from the problem location and the representation of the type in the code, so it might be better to point to the start of the path rather than the end of the path. (The A and B in the declaration of C.) Or maybe all four locations.

The situation is made even worse in the presence of augmentations because the two types might be introduced in different declarations. That kind of makes the argument in favor of pointing at the start of the path stronger.

bwilkerson avatar Feb 12 '24 22:02 bwilkerson