-
-
Save jll63/0ca76976aee729c3c5ca591b8c7c18cd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module common; | |
class A {} | |
class B : A {} | |
class C : B {} | |
void foo(virtual A) {} | |
// --- | |
module one; | |
import common; | |
import two; | |
void foo(virtual B) {} | |
alias foo = common.foo; | |
// override void foo(virtual C) {} // ambiguous | |
override void common.foo(virtual C) {} // OK | |
void bar() | |
{ | |
foo(new A); // call common.foo(virtual A) | |
foo(new B); // call two.foo(virtual B) | |
foo(new C); // call one.foo(virtual C) | |
} | |
// --- | |
module two; | |
import common; | |
override void foo(virtual B) {} | |
void bar() | |
{ | |
foo(new C); // will call one.foo(virtual C) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment