summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2025-06-11 12:12:53 -0700
committerGitHub <noreply@github.com>2025-06-11 12:12:53 -0700
commit45560483447dd737a63efc236b2be07fd0fc4347 (patch)
treed0bc2e90d3aa0bfb630e02789ad6d38986cbc2a6 /tests
parent5a851fe846bb4b3657dfc94a88fcce7b1221a8eb (diff)
Fix an issue in extension override. (#7402)
* Fix an issue in extension override. * Fix typo in comment.
Diffstat (limited to 'tests')
-rw-r--r--tests/language-feature/extensions/extension-override-2.slang41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/language-feature/extensions/extension-override-2.slang b/tests/language-feature/extensions/extension-override-2.slang
new file mode 100644
index 000000000..bd40e8ba9
--- /dev/null
+++ b/tests/language-feature/extensions/extension-override-2.slang
@@ -0,0 +1,41 @@
+//TEST:INTERPRET(filecheck=CHECK):
+interface IBar
+{}
+
+interface IFoo : IBar
+{
+ void execute();
+}
+
+struct Impl : IFoo
+{
+ void execute()
+ {
+ printf("Impl::execute();\n");
+ }
+}
+
+extension<T:IBar> T : IFoo
+{
+ void execute()
+ {
+ printf("Extension::execute();\n");
+ }
+}
+
+struct Base : IBar{}
+
+void test<T:IFoo>(T t)
+{
+ t.execute();
+}
+
+void main()
+{
+ // CHECK: Impl::execute();
+ Impl f;
+ test(f);
+ // CHECK: Extension::execute();
+ Base b;
+ test(b);
+} \ No newline at end of file