this slack <thread> discusses a workaround that pe...
# compiler
a
this slack thread discusses a workaround that perhaps highlights a minor quirk in the compiler deserving attention and could maybe be considered for a fix
d
There are two reasons behind this behavior: 1. Parser expects some expression after
by
keyword, and infix call of function is also expression 2.
where
is soft keyword, which means it parses like keyword only in specific context (after supertypes list and before body of class). In other contexts
where
is parsed as regular modifier This all leads to situation from your example and it's more or less expected As it was suggested in in original thread, there is a workaround with additional newline (
\n
in this case assumed as end of expression) Also if
where
were harder keyword then such code (esoteric, but still meaningful) will be impossible to write:
Copy code
interface A

infix fun String.where(other: String): A = TODO()

const val B = "B"
const val C = "C"

class Impl<T> : A by B where C // `where` us call of function
    where T : CharSequence // `where` is keyword
a
Dmitriy: thanks for taking the time to answer. I hear you, that sounds reasonable, and the workaround (add new line) makes sense and is simple. Cheers!