Class RedundantTraitReference

java.lang.Object
org.ek9lang.compiler.repair.RedundantTraitReference

public final class RedundantTraitReference extends Object
THE E02090 repair - a trait listed beside another listed trait that already has it (with trait of LoudSpeaker, Speaker where LoudSpeaker with trait of Speaker) - which has ONE reading: delete the redundant name (Steve, 2026-10-11). Use this; do not re-derive it.

The compiler has proved that the second name adds nothing: everything it brings is already inherited through the trait that has it, so deleting it leaves the type exactly as it was. The E02090 message names both traits ('Speaker' is already a trait of 'LoudSpeaker'); the diagnostic's line is the declaration's.

Deliberately conservative: applied only where the diagnostic's line holds a trait of list with the redundant name in it exactly ONCE (a name listed twice is E02050, not this), as a bare name - an entry with a by delegate is left alone, since dropping it would drop that delegation too. A qualified entry (module::Speaker) matches by its simple name. Rewrites within one line; the caller re-verifies.

A listed trait the SUPER CLASS already has is the same error with the same reading (Steve, 2026-10-12, decision (a)): 'Speaker' is already a trait of 'Base'. When it is the only trait listed, the whole with trait of Speaker clause is deleted (Announcer extends Base).

  • Method Details

    • mayApply

      public static boolean mayApply(String text)
      True when text holds a trait list of more than one entry, or one after an extends - the cheap gate before a probe compile.
    • repaired

      public static String repaired(String line, String redundant)
      One line with redundant deleted from its trait list, or null when the shape is not there.
    • repair

      public static RedundantTraitReference.Result repair(String text, List<Map<String,Object>> diagnostics)
      Delete the redundant trait each E02090 diagnostic names.