diff --git a/src/back/CodeGen/MethodDecl.hs b/src/back/CodeGen/MethodDecl.hs index 7a50c77b0..a543095fc 100644 --- a/src/back/CodeGen/MethodDecl.hs +++ b/src/back/CodeGen/MethodDecl.hs @@ -101,7 +101,7 @@ translateGeneral mdecl@(A.Method {A.mbody, A.mlocals}) argNames = map (AsLval . argName) encArgNames argTypes = map translate encArgTypes subst = [(ID.thisName, thisVar)] ++ - varSubFromTypeVars typeVars ++ + varSubFromTypeVars (typeVars ++ mTypeVars) ++ zip encArgNames argNames ctx = Ctx.setMtdCtx (Ctx.new subst newTable) mdecl forwardingCtx = Ctx.setMtdCtx(Ctx.newWithForwarding subst newTable) mdecl @@ -122,7 +122,7 @@ translateGeneral mdecl@(A.Method {A.mbody, A.mlocals}) (Deref $ Cast (Ptr . AsType $ classTypeName cname) thisVar) `Dot` name - closures = map (\clos -> translateClosure clos typeVars newTable) + closures = map (\clos -> translateClosure clos (typeVars ++ mTypeVars) newTable) (reverse (Util.filter A.isClosure mbody)) localize cls prefix fun = diff --git a/src/tests/encore/parametric/methodPolyClosure.enc b/src/tests/encore/parametric/methodPolyClosure.enc new file mode 100644 index 000000000..a990de830 --- /dev/null +++ b/src/tests/encore/parametric/methodPolyClosure.enc @@ -0,0 +1,18 @@ +read class Bar[t] + def bar() : unit + println("In Bar") + end +end + +read class Foo + def foo[ty]() : () -> unit + fun() => (new Bar[ty]()).bar() + end +end + +active class Main + def main() : unit + val f = (new Foo()).foo[int]() + f() + end +end diff --git a/src/tests/encore/parametric/methodPolyClosure.out b/src/tests/encore/parametric/methodPolyClosure.out new file mode 100644 index 000000000..b3834d927 --- /dev/null +++ b/src/tests/encore/parametric/methodPolyClosure.out @@ -0,0 +1 @@ +In Bar