mirror of
https://github.com/dlang/phobos.git
synced 2025-05-11 06:28:28 +03:00
Merge pull request #5858 from BBasile/issue-12064
fix issue 12064 - std.typecons.wrap doesn't handle NVI merged-on-behalf-of: MetaLang <MetaLang@users.noreply.github.com>
This commit is contained in:
commit
d1a0a32e79
1 changed files with 35 additions and 1 deletions
|
@ -4684,6 +4684,13 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
|
||||||
alias type = F;
|
alias type = F;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// issue 12064: Remove NVI members
|
||||||
|
template OnlyVirtual(members...)
|
||||||
|
{
|
||||||
|
enum notFinal(alias T) = !__traits(isFinalFunction, T);
|
||||||
|
alias OnlyVirtual = Filter!(notFinal, members);
|
||||||
|
}
|
||||||
|
|
||||||
// Concat all Targets function members into one tuple
|
// Concat all Targets function members into one tuple
|
||||||
template Concat(size_t i = 0)
|
template Concat(size_t i = 0)
|
||||||
{
|
{
|
||||||
|
@ -4691,9 +4698,10 @@ if (Targets.length >= 1 && allSatisfy!(isMutable, Targets))
|
||||||
alias Concat = AliasSeq!();
|
alias Concat = AliasSeq!();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
alias Concat = AliasSeq!(GetOverloadedMethods!(Targets[i]), Concat!(i + 1));
|
alias Concat = AliasSeq!(OnlyVirtual!(GetOverloadedMethods!(Targets[i]), Concat!(i + 1)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicated functions based on the identifier name and function type covariance
|
// Remove duplicated functions based on the identifier name and function type covariance
|
||||||
template Uniq(members...)
|
template Uniq(members...)
|
||||||
{
|
{
|
||||||
|
@ -5059,6 +5067,32 @@ if (!isMutable!Target)
|
||||||
assert(i.bar(10) == 100);
|
assert(i.bar(10) == 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@system unittest // issue 12064
|
||||||
|
{
|
||||||
|
interface I
|
||||||
|
{
|
||||||
|
int foo();
|
||||||
|
final int nvi1(){return foo();}
|
||||||
|
}
|
||||||
|
|
||||||
|
interface J
|
||||||
|
{
|
||||||
|
int bar();
|
||||||
|
final int nvi2(){return bar();}
|
||||||
|
}
|
||||||
|
|
||||||
|
class Baz
|
||||||
|
{
|
||||||
|
int foo() { return 42;}
|
||||||
|
int bar() { return 12064;}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto baz = new Baz();
|
||||||
|
auto foobar = baz.wrap!(I, J)();
|
||||||
|
assert(foobar.nvi1 == 42);
|
||||||
|
assert(foobar.nvi2 == 12064);
|
||||||
|
}
|
||||||
|
|
||||||
// Make a tuple of non-static function symbols
|
// Make a tuple of non-static function symbols
|
||||||
package template GetOverloadedMethods(T)
|
package template GetOverloadedMethods(T)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue