Class Redeclaration
java.lang.Object
org.ek9lang.compiler.repair.Redeclaration
THE E50050 repair - a name declared a second time with
<- - where the second <- has ONE
reading, for every editing tool. Use this; do not re-derive it. Where two readings compile,
the MCP RedeclarationHint names both instead.
<- declares a NEW variable, so a second one for a name already in scope never compiles
(E50050). Two cases leave a single reading, and each becomes an assignment within its own line:
- The member's return, declared again in its body -
rtn <- String()under<- rtn as String?. The signature cannot be removed, so the body can only be assigning it:rtn: String(). 154 of the 223 E50050 refusals in the harness record. - A local used between its two declarations -
full <- ..., aprintln(full), thenfull <- ...again. Replacing the earlier line instead would usefullbefore it is declared (E08010, measured 2026-09-29), so the second can only befull := ....
With nothing between them both readings compile and differ - reassigning runs the first value too - so that case is skipped and the hint stands. The caller re-verifies whatever this proposes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA second declaration as the E50050 message names it - THE reading of that message for this repair and for the MCPRedeclarationHint: the name, the line declaring it again, the line that declared it first.static final recordThe rewritten text and one note per rewrite;notesempty means nothing moved. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanTrue whentextdeclares a name twice with<-, or declares with<-a name it also returns - the cheap gate before a probe compile.static Redeclaration.ResultMake each second declaration an assignment where it has one reading.(package private) static booleanusedBetween(List<String> lines, int earlierLine, int line, String name) Isnameread on a line strictly between the two declarations - outside double-quoted Strings and comments (a backtick String's${name}is a read)?
-
Method Details
-
mayApply
True whentextdeclares a name twice with<-, or declares with<-a name it also returns - the cheap gate before a probe compile. -
repair
-
usedBetween
-