Closed
Description
I used Java 11 for a long time and I had an extension method indent
on String
that indents a string.
Java 12 and above introduced its own indent
method. As a result, my existing code broke, like demonstrated in the following code.
Compiler version
v3.2.2-RC2
Minimized code
extension (text: String)
def indent: String = text
println("hello".indent)
Output
Under Java 12 and above:
Playground$$$Lambda$7955/0x00000008010fc800@4e7d4166
Expectation
Print hello
or at least give a warning/error that overloading existing class methods via extension methods is not possible.