Skip to content

Instantly share code, notes, and snippets.

@jll63
Last active July 13, 2018 15:04
Show Gist options
  • Save jll63/0ca76976aee729c3c5ca591b8c7c18cd to your computer and use it in GitHub Desktop.
Save jll63/0ca76976aee729c3c5ca591b8c7c18cd to your computer and use it in GitHub Desktop.
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