ceylon icon indicating copy to clipboard operation
ceylon copied to clipboard

parameter type inference for anonymous functions in assignments

Open fwgreen opened this issue 8 years ago • 6 comments

Here is one possible use case

shared Object bar(Request req, Response res) => "Hello";
shared Object baz(Request req, Response res) => "World ";
// ...
//vs
shared alias Route => Object(Request, Response);
shared Route bar = (req, res) => "Hello";
shared Route baz = (req, res) => "World";
// ...

fwgreen avatar May 06 '17 15:05 fwgreen

Given that I'm doing work in this area now, as a consequence of #6615, time is probably ripe to make a start on this issue.

gavinking avatar Apr 17 '18 10:04 gavinking

This is now basically done, on the 6615 branch.

gavinking avatar Apr 18 '18 16:04 gavinking

I just tried it, and it doesn't appear to be working:

error: parameter is not declared explicitly, and its type cannot be inferred:

fwgreen avatar Apr 18 '18 18:04 fwgreen

@fwgreen I just tried it with this code:

shared interface Request {}
shared interface Response {}

shared alias Route => Object(Request, Response);
shared Route bar = (req, res) => "Hello";
shared Route baz = (req, res) => "World";

and it worked.

Are you sure you're on the right branch?

gavinking avatar Apr 18 '18 20:04 gavinking

@gavinking I cloned it again and this time it works! Thanks!

fwgreen avatar Apr 18 '18 20:04 fwgreen

I've merged this work to master. Still need to define it in the spec.

gavinking avatar Apr 18 '18 20:04 gavinking