Infix precedence


Is there anyway to get the following to compile without using parenthesis.

  infix fun String.b(k: Int) {  }
  infix fun String.e(b: Boolean): Int = 0

  "a" b ("c" e false) // compiles
  "a" b "c" e false // fails

I was hoping the compiler would look ahead and see that the infix e can work for c and false and give the value that b needs without me having to specify the order via parenthesis.


What if I wrote a code like this:

  infix fun String.b(s: String):String { return this}
  infix fun String.e(b: Boolean): Int = 0

Now I can do:

"a" b "c" e false

But this calculation is from left to right.
In most languages we read and write from left to right.


it is equal to



That’s not infix though is it.


Thanks, but should have added I can’t change the original methods. I guess its just a limitation I’ll have to accept.