Czar
11/01/2017, 1:13 PMapply
whose argument is a SAM from guava. Since some of us started using K we bump into the conflict with Kotlin's apply
quite often. I'm considering the resolution options and so far found only two. Did I miss anything?
1. rename member apply
to something like applyFunction
(involves convincing several teamleads who do not use K )
2. specify the receiver type (someInstanceOfBase.apply<Base> { ... }
) (suggested by @marstran)
3. accept that this is the reality and use also
instead of apply
4. duplicate Kotlin's apply
and rename that (suggested by @karelpeeters)
Here's the recipe for the disaster at hand 🙂 (irrelevant parts omitted for brevity)
☕
import com.google.common.base.Function;
public abstract class Base {
public <T, F> T apply(Function<F, T> function) {
return function.apply((F) this);
}
}
Shawn
11/01/2017, 1:20 PMapply
conflict occurs - any chance we could get a code sample?Czar
11/01/2017, 1:26 PMimport kotlin.apply as kapply
This works, but I'm not sure yet how I feel about it and where to put it in the options list 🙂
So far renaming member apply is still my number one, unfortunately.