[Chapel Merge] IFC: Allow wrappers to implement required function

Branch: refs/heads/master
Revision: 0a4c2e9
Author: vasslitvinov
Log Message:

Merge pull request #17832 from vasslitvinov/ifc-wrappers

IFC: Allow wrappers to implement required functions

This allows an implementation, or "witness", of a required function of an
interface, to be extended with conversions.

With this change, the following cases become possible
(see also the newly-added wrappers-for-impl-functions.chpl) :

interface IFC(Self) {
  proc reqFn(arg: Self): void;
}

int implements IFC;

// various cases of implementing IFC's required function to be supported
proc reqFn(arg: real) {...}  // needs coercion int->real
proc reqFn(arg1: int, arg2: int = 0) {...} // needs a default argument

implements IFC(bool(8));
proc reqFn(arg: bool) {...}  // needs coercion for non-default-sized bools

interface StdOps(Val) {
  operator ==(arg1: Val, arg2: Val): bool;
}

// needs coercion to use the predefined operator == on 'borrowed object'
implements StdOps(borrowed MyClass);

To support this, the compiler replaces the original witness with a wrapper
that performs the necessary conversions then invokes the original witness.
A couple of curious cases where a wrapper is created:

  • if the original witness is a param function
  • when the interface requires an operator written as a standalone function
    whereas its witness is written as a type method

Now that implements statements work well with class types, I reshuffled
a couple of tests with minFn and classes so that there
are tests that compile and run properly and a future test asking how
to write minFn so it allows being used with owned classes.

A couple of other tests are now working as desired, so I unfuturized them.

r: @mppf

Modified Files:
A test/constrained-generics/basic/set2/wrappers-for-impl-functions.chpl

A test/constrained-generics/basic/set2/wrappers-for-impl-functions.good
A test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_2.bad
A test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_2.chpl
A test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_2.future
A test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_2.good
R test/constrained-generics/basic/set2/param-implementation-of-non-param.bad
R test/constrained-generics/basic/set2/param-implementation-of-non-param.future
R test/constrained-generics/ucol/cwailes-1/tier_1_class_type.bad
R test/constrained-generics/ucol/cwailes-1/tier_1_class_type.future
R test/constrained-generics/ucol/cwailes-1/tier_1_interface_method.bad
R test/constrained-generics/ucol/cwailes-1/tier_1_interface_method.future
R test/constrained-generics/ucol/cwailes-1/tier_1_num_coerce2.bad
R test/constrained-generics/ucol/cwailes-1/tier_1_num_coerce2.future
R test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_0.bad
R test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_0.future
R test/constrained-generics/ucol/neelam/min_concept_class_coercion.bad
R test/constrained-generics/ucol/neelam/min_concept_class_coercion.future
M compiler/resolution/interfaceResolution.cpp
M test/constrained-generics/random/demo-random.chpl
M test/constrained-generics/random/test-random.chpl
M test/constrained-generics/ucol/cwailes-1/tier_1_class_type.chpl
M test/constrained-generics/ucol/cwailes-1/tier_1_class_type.good
M test/constrained-generics/ucol/cwailes-1/tier_1_interface_method.chpl
M test/constrained-generics/ucol/cwailes-1/tier_1_interface_method.good
M test/constrained-generics/ucol/cwailes-1/tier_1_num_coerce2.good
M test/constrained-generics/ucol/cwailes-1/tier_1_subtyping_0.chpl
M test/constrained-generics/ucol/jsiek/test_method_in_interface.bad
M test/constrained-generics/ucol/jsiek/test_method_in_interface.future
M test/constrained-generics/ucol/neelam/min_concept_class_coercion.chpl

Compare: https://github.com/chapel-lang/chapel/compare/8147cacafb01...0a4c2e9c023d