petdance/scratch — Issue #1218: Overriding one signature of  a multi-method in a subclass prevents access to the other signatures
Author: petdance
Created: 2011-11-01 05:39:36+00:00
State: open
Labels: bug, core, Pri-normal, Sev-medium

If a class defines a multi-method with multiple signature, a sub-class cannot override only some signatures of the multi-method and still inherit the remaining signatures.
For an example:

{{{
class A {
our multi method foo (Integer $i) {
self.foo(~$i);
}

our multi method foo (String $s) {
say($s);
}
}

class B is A {
our multi method foo (Integer $i) {
self.foo(~($i + 1));
}
}

A.new.foo(1);

B.new.foo(1);
}}}

And the output of running it:

{{{
$ ./parrot-nqp test.nqp
1
No applicable candidates found to dispatch to for 'foo'
current instr.: 'parrot;B;foo' pc 329 (EVAL_1:33777434)
called from Sub '_block11' pc 97 (EVAL_1:33777341)
called from Sub 'parrot;HLL;Compiler;_block465' pc 23452 (ext/nqp-rx/src/stage0/HLL-s0.pir:7654)
called from Sub 'parrot;HLL;Compiler;eval' pc 23332 (ext/nqp-rx/src/stage0/HLL-s0.pir:7622)
called from Sub 'parrot;PCT;HLLCompiler;evalfiles' pc 1500 (compilers/pct/src/PCT/HLLCompiler.pir:761)
called from Sub 'parrot;PCT;HLLCompiler;command_line' pc 1702 (compilers/pct/src/PCT/HLLCompiler.pir:869)
called from Sub 'parrot;NQP;Compiler;main' pc 83871 (ext/nqp-rx/src/stage0/NQP-s0.pir:23065)
}}}

Originally http://trac.parrot.org/parrot/ticket/1690