[PEAK] dispatch.strategy.ProtocolTest bug
Radek Kanovsky
rk at dat.cz
Mon Nov 22 12:27:05 EST 2004
There is problem with ProtocolTest if declaration order is as follows:
from peak.core import *
class Iface1 (protocols.Interface) : pass
class Iface2 (protocols.Interface) : pass
[dispatch.generic()]
def gm (a) : pass
[gm.when("a in Iface1")]
def gm1 (a) : return "gm1"
[gm.when("a in Iface2")]
def gm2 (a) : return "gm2"
class Impl1 : protocols.advise(instancesProvide=[Iface1])
class Impl2 : protocols.advise(instancesProvide=[Iface2])
print gm(Impl1())
print gm(Impl2())
'gm(Impl1())' statement raises 'AmbiguousMethod' exception.
If declaration of class 'ImplX' is moved before `a in IfaceX'
predicate occurence, generic function returns expected results.
RadekK
More information about the PEAK
mailing list