# New Ticket Created by  Moritz Lenz 
# Please include the string:  [perl #114634]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=114634 >


"Just because it's an A doesn't mean it can't be a B"

Consider

{
    my class A {};
    my class B { };
    my class C is B is A {};
    multi f(A) { "A" };
    multi f(B) { "B" };
    sub g(A $x) { say f($x) };  # type A
    g(C.new);
}

# prints A

{
    my class A {};
    my class B { };
    my class C is B is A {};
    multi f(A) { "A" };
    multi f(B) { "B" };
    sub g(A $x) { say f($x) };  # type A
    g(C.new);
}

# prints B

and with the optimizer turned off, both print

Ambiguous call to 'f'; these signatures all match:
:(A )
:(B )


Found by sorear++

Reply via email to