https://kotlinlang.org logo
Title
e

edwardwongtl

04/26/2018, 5:39 AM
I got a question about
@Deprecated
and
ReplaceWith()
, while replacing normal functions works fine, replacing infix function will be like this
@Deprecated(..., replaceWith = ReplaceWith("bar(x)"))
infix fun Foo.foo(x: Int) = ...
infix fun Foo.bar(x: Int) = ...

foo foo 10
// After replacement becomes
foo.bar(10)
is there anyway for the IDE do the replacement such that it becomes
foo bar 10
?
g

gildor

04/26/2018, 5:47 AM
This replacement works for me, I use Kotlin Plugin 1.2.40
e

edwardwongtl

04/26/2018, 5:48 AM
1.2.40 as well here, could you try the other example?
g

gildor

04/26/2018, 5:49 AM
I tried your example above, works perfectly
e

edwardwongtl

04/26/2018, 5:50 AM
How about
a + b foo 10
into
a + b bar 10
?
I can only get
(a + b).bar(10)
or
(a+b) bar 10
g

gildor

04/26/2018, 5:50 AM
yes,
(a + b).bar(10)
but it’s correct
I see what you mean
e

edwardwongtl

04/26/2018, 5:51 AM
I know it's correct, just does look nice
The IDE can do better
g

gildor

04/26/2018, 5:51 AM
Create an issue
btw
(a + b) foo 10
works perfectly, replaced to
(a + b) bar 10
actually this style
a + b foo 10
is very confusing, probably IDE should warn user to avoid it and ask to add parenthesis
e

edwardwongtl

04/26/2018, 5:54 AM
Maybe this example is confusing, but I am doing
a bindTo b until event
in my project, which should be better?
g

gildor

04/26/2018, 5:55 AM
yes, you right, if you have only infix function it’s much better and not confusing
e

edwardwongtl

04/26/2018, 5:56 AM
I guess I'll let JetBrains decide which approach is better, warning for parenthesis or better replacement.