--- Comment #20 from 2012-02-04 10:05:05 PST ---
(In reply to comment #19)
> (In reply to comment #18)
> > (In reply to comment #17)
> > > try at a minimum immutable, mutable, and inout.  If more than one of these
> > > typechecks, the call is ambiguous.
> > 
> > What if one is a better match than the other? If it should fail I think we
> > should use the repaired overload resolution. It has exactly the required
> > semantics.
> Example?  How can immutable match "better" than mutable?  I guess it would
> depend on the definition of "better".

class A{
    A x()const{return new A;}
    alias x this;

int foo(immutable(A) x){return 1;}
int foo(A x){return 2;}

static assert(foo(new immutable(A)) == 1);

The overload is resolved to the first function because it is an exact match
whereas the second overload is a match with implicit conversions. Your proposed
rules would always use the alias this when matching an inout(A) parameter, and
that is probably not what is wanted. Interestingly, the compiler currently
seems to explore the alias this of the alias this of the alias this... and
never terminates. (Also see issue 7437).

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to