LuaLS / LuaLS/lua-language-server
FR: Allow 'self' return type to allow return type changing with inheritance
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Lua
- Sterne
- 4.4k
- Forks
- 442
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
When annotating that one class has inherited from another, there is currently no way to annotate a function that returns it's current type that the current type should change when the class is inherited. Something along these lines, or something that accomplishes the same goal would be fantastic.
```lua
---@class Foo
Foo = {}
---@return self --<-- 'self' refers to Foo so Foo.new() returns Foo
function Foo.new() end
---@class Bar : Foo
Bar = {}
local b = Bar.new() --<-- Bar.new() is inherited so the 'self' return type is now Bar
-- b should now be type Bar
```
Thanks!
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem Foo/Bar-Lua-Beispiel im Issue und verfolge nach, wie @return-Annotationen und geerbte Methoden interpretiert werden. Als abgeschlossen gilt die Aufgabe, wenn ein von Bar geerbter Konstruktor sein Ergebnis als Bar statt als Foo inferiert, mit Abdeckung des demonstrierten Verhaltens.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 30/100