0
0
mirror of https://github.com/vim/vim.git synced 2025-10-03 05:14:07 -04:00

patch 9.0.1178: a child class cannot override functions from a base class

Problem:    A child class cannot override functions from a base class.
Solution:   Allow overriding and implement "super".
This commit is contained in:
Bram Moolenaar
2023-01-11 15:59:05 +00:00
parent ad15a39fdb
commit 58b40092e6
8 changed files with 136 additions and 16 deletions

View File

@@ -817,6 +817,27 @@ def Test_class_extends()
endclass
END
v9.CheckScriptFailure(lines, 'E1354: Cannot extend SomeVar')
lines =<< trim END
vim9script
class Base
this.name: string
def ToString(): string
return this.name
enddef
endclass
class Child extends Base
this.age: number
def ToString(): string
return super.ToString() .. ': ' .. this.age
enddef
endclass
var o = Child.new('John', 42)
assert_equal('John: 42', o.ToString())
END
v9.CheckScriptSuccess(lines)
enddef