#2483 Method.func.typeof is not parameterized

SlimerDude Thu 8 Oct 2015

I was surprised to find that Method funcs are generic:

static Void method(StrBuf buf, Err? err) { }

...

func := |StrBuf buf, Err? err| { }  // --> prints correct signature
meth := #method.func                // --> prints generic signature
	
echo("\n-- Func:")
echo("isGeneric: ${func.typeof.isGeneric}")
echo("Signature: ${func.typeof.signature}")
echo("params   : ${func.params}")

echo("\n-- Meth:")
echo("isGeneric: ${meth.typeof.isGeneric}")
echo("Signature: ${meth.typeof.signature}")
echo("params   : ${meth.params}")

Heralds:

-- Func:
isGeneric: false
Signature: |sys::StrBuf,sys::Err?->sys::Void|
params   : [sys::StrBuf buf, sys::Err? err]

-- Meth:
isGeneric: true
Signature: sys::Func
params   : [sys::StrBuf buf, sys::Err? err]

I would have expected the output from meth to be identical to that of func. Given methods have known parameters, I would have expected their type information to be pre-filled.

My current work around (as I do a lot of type checking) is to retype the method func:

meth := #method.func.retype(|StrBuf, Err?|#)
	
echo("\n-- Meth:")
echo("Signature: ${meth.typeof.signature}")
echo("isGeneric: ${meth.typeof.isGeneric}")
echo("params   : ${meth.params}")

...

-- Meth:
Signature: |sys::StrBuf,sys::Err?->sys::Void|
isGeneric: false
params   : [sys::StrBuf a, sys::Err? b]

But it seems silly to have to do that!?

brian Wed 4 Oct

Ticket promoted to #2483 and assigned to brian

brian Wed 4 Oct

Ticket resolved in 1.0.70

changeset

Login or Signup to reply.