eclipse-archived / ceylon

The Ceylon compiler, language module, and command line tools
http://ceylon-lang.org
Apache License 2.0
399 stars 62 forks source link

name clash ceylon backend error #7437

Open MikhailMalyutin opened 6 years ago

MikhailMalyutin commented 6 years ago

Next code:

@FunctionalInterface
public
interface BiIntPredicate<T> {
    boolean test(T t, int u);
}

@FunctionalInterface
public
interface BiIntFunction<T, R> {
    R apply(T t, int u);
}

shared BiIntPredicate<T> toBiIntPredicate<T>(Boolean(T, Integer) fn) given T satisfies Object {
    return object satisfies BiIntPredicate<T>  {
        shared actual Boolean test(T t, Integer u) {
            return fn(t, u);
        }
    };
}

shared BiIntFunction<T, R> toBiIntFunction<T, R>(R(T, Integer) fn) given T satisfies Object given R satisfies Object {
    return object satisfies BiIntFunction<T, R> {
        shared actual R apply(T t, Integer u) {
            return fn(t, u);
        }
    };
}

Ceylon IDE shows no problems.

But after ceylon compile we see:

error: Ceylon backend error: name clash: test(T#1,int) in anonymous_0_ and test(T#2,int) in BiIntPredicate have the same erasure, yet neither overrides the other
        shared actual Boolean test(T t, Integer u) {
               ^
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in method <T#1>toBiIntPredicate(TypeDescriptor,Callable<? extends Boolean>)
    T#2 extends Object declared in interface BiIntPredicate
source/problemcode.ceylon:15: error: Ceylon backend error: name clash: apply(T#1,int) in anonymous_1_ and apply(T#2,int) in BiIntFunction have the same erasure, yet neither overrides the other
        shared actual R apply(T t, Integer u) {
               ^
  where T#1,R#1,T#2,R#2 are type-variables:
    T#1 extends Object declared in method <T#1,R#1>toBiIntFunction(TypeDescriptor,TypeDescriptor,Callable<? extends R#1>)
    R#1 extends Object declared in method <T#1,R#1>toBiIntFunction(TypeDescriptor,TypeDescriptor,Callable<? extends R#1>)
    T#2 extends Object declared in interface BiIntFunction
    R#2 extends Object declared in interface BiIntFunction
2 errors