Skip to content

Dotty allows private method to override public method implicitly #8005

Closed
@molikto

Description

@molikto

minimized code

package nio {
	abstract class Buffer {
		val isReadOnly: Boolean
	}

	abstract class ByteBuffer extends Buffer {
		private[nio] val isReadOnly: Boolean = false
	}
}

expectation

This should not compile, scalac complains with:

B.scala:8: error: weaker access privileges in overriding
val isReadOnly: Boolean (defined in class Buffer)
  override should not be private
		override private val isReadOnly: Boolean = false
                                     ^
one error found

The same thing happens with private[nio] replace with private

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions