Mercurial > vim
comparison src/testdir/test_vim9_class.vim @ 31843:ffa11e2757e7 v9.0.1254
patch 9.0.1254: calling a method on an interface does not work
Commit: https://github.com/vim/vim/commit/d0200c8631582bbb16a9b585e2ca7adccc84ccdd
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jan 28 15:19:40 2023 +0000
patch 9.0.1254: calling a method on an interface does not work
Problem: Calling a method on an interface does not work.
Solution: At runtime figure out what method to call. (closes https://github.com/vim/vim/issues/11901)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 28 Jan 2023 16:30:04 +0100 |
parents | 5ce5d78afcc9 |
children | dbec60b8c253 |
comparison
equal
deleted
inserted
replaced
31842:1b6543beb560 | 31843:ffa11e2757e7 |
---|---|
999 Test() | 999 Test() |
1000 END | 1000 END |
1001 v9.CheckScriptSuccess(lines) | 1001 v9.CheckScriptSuccess(lines) |
1002 enddef | 1002 enddef |
1003 | 1003 |
1004 def Test_call_interface_method() | |
1005 var lines =<< trim END | |
1006 vim9script | |
1007 interface Base | |
1008 def Enter(): void | |
1009 endinterface | |
1010 | |
1011 class Child implements Base | |
1012 def Enter(): void | |
1013 g:result ..= 'child' | |
1014 enddef | |
1015 endclass | |
1016 | |
1017 def F(obj: Base) | |
1018 obj.Enter() | |
1019 enddef | |
1020 | |
1021 g:result = '' | |
1022 F(Child.new()) | |
1023 assert_equal('child', g:result) | |
1024 unlet g:result | |
1025 END | |
1026 v9.CheckScriptSuccess(lines) | |
1027 | |
1028 lines =<< trim END | |
1029 vim9script | |
1030 class Base | |
1031 def Enter(): void | |
1032 g:result ..= 'base' | |
1033 enddef | |
1034 endclass | |
1035 | |
1036 class Child extends Base | |
1037 def Enter(): void | |
1038 g:result ..= 'child' | |
1039 enddef | |
1040 endclass | |
1041 | |
1042 def F(obj: Base) | |
1043 obj.Enter() | |
1044 enddef | |
1045 | |
1046 g:result = '' | |
1047 F(Child.new()) | |
1048 assert_equal('child', g:result) | |
1049 unlet g:result | |
1050 END | |
1051 v9.CheckScriptSuccess(lines) | |
1052 enddef | |
1053 | |
1004 def Test_class_used_as_type() | 1054 def Test_class_used_as_type() |
1005 var lines =<< trim END | 1055 var lines =<< trim END |
1006 vim9script | 1056 vim9script |
1007 | 1057 |
1008 class Point | 1058 class Point |