Dotty: java.nio.Buffer.isReadOnly method is not accessible

Created on 29 Aug 2019  路  3Comments  路  Source: lampepfl/dotty

scala> java.nio.ByteBuffer.allocate(1).isReadOnly

Scala 2 returns false as expected.

Dotty displays the following error message instead:

variable isReadOnly cannot be accessed as a member of java.nio.ByteBuffer from module class rs$line$1$

Same applies to CharBuffer, IntBuffer, LongBuffer, et al.

java scala2 bug

Most helpful comment

We should keep the issue open since there's still a bug on Dotty's side here :).

All 3 comments

This can be worked around by upcasting ByteBuffer to Buffer:

(java.nio.ByteBuffer.allocate(1): java.nio.Buffer).isReadOnly

isReadOnly() is a public method in java.nio.Buffer, java.nio.ByteBuffer extends this class but also contains a non-public field called isReadOnly which is what Dotty ends up trying to call, even though it's a non-accessible overload.

Thanks

We should keep the issue open since there's still a bug on Dotty's side here :).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

odersky picture odersky  路  3Comments

Blaisorblade picture Blaisorblade  路  3Comments

julienrf picture julienrf  路  3Comments

fommil picture fommil  路  3Comments

dwijnand picture dwijnand  路  3Comments