New Issue: CG: implicit conversion for interface-constrained functions?

17540, "vasslitvinov", "CG: implicit conversion for interface-constrained functions?", "2021-04-08T02:31:48Z"

main issue: #8629     related: #16412

Do we want to support coercions aka implicit conversions for arguments to interface-constrained functions?

For example, given:

proc myfun(arg: ?T) where T implements MyInterface { ... }

implements MyInterface(real);
implements MyInterface(borrowed MyClass?);

are the following calls allowed?

myfun(1); // coerces to 'real'
myfun([1.1, 2.2, 3.3]); // requires promotion of myfun(T=real)
myfun([1,2,3]); // a combination of the above two

myfun(new borrowed MyClass()); // non-nilable coerces to nilable
myfun(new MyClass?()); // owned coerces to nilable
myfun(new MyClass()); // a combination of the above two
myfun(new borrowed MySubclass?()); // MySubclass coerces to MyClass

From the user perspective, it is natural to allow such calls.
However, it unclear how to define or implement this semantics. Also...

The same question arises with traditional aka "unconstrained" generics.
The answer there is "no": the query type matches the actual argument's type exactly.

The exception to this rule with traditional generics is for type formals, where subtyping is allowed,
for example:

class MyClass { }
class MySubclass : MyClass { }

proc foo(type argT: MyClass) { ... }
foo(owned MySubclass);  // argT == owned MyClass

How does this apply to interface generics?