LuaLS / LuaLS/lua-language-server
FR: Allow 'self' return type to allow return type changing with inheritance
Nessuno ha ancora preso questa issue.
- Lingua principale
- Lua
- Stelle
- 4.4k
- Fork
- 442
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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.
---@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!
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia con l’esempio Lua di Foo/Bar nell’issue e segui come vengono interpretate le annotazioni @return e i metodi ereditati. Il lavoro è completo quando un costruttore ereditato da Bar deduce il proprio risultato come Bar anziché Foo, con una copertura del comportamento mostrato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- lua
- Ambito
- devtools
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100