Skip to content

Ambiguous overload using JDK 11 #10715

Closed
@noti0na1

Description

@noti0na1

Minimized code

The following code can be compiled using JDK 8. However, it will output ambiguous overload error when using JDK 11.

Environment:
Ubuntu
openjdk 1.8.0_275
openjdk 11.0.9.1

val decoderOut = java.nio.CharBuffer.allocate(1000)
val p = decoderOut.position

Output

-- [E051] Reference Error: Stest.scala:7:19 ------------------------------------
7 |val p = decoderOut.position
  |        ^^^^^^^^^^^^^^^^^^^
  |Ambiguous overload. The overloaded alternatives of method position in class CharBuffer with types
  | (x$0: Int): java.nio.CharBuffer
  | (): Int
  |both match expected type <?>

Expectation

The compiler shoud find and use position(): Int here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions