Skip to content

Regression: Can't override java defined method which have variable with same name #9392

Closed
@ohze

Description

@ohze

Minimized code

class C extends java.util.LinkedList[String] {
  override def size(): Int = super.size()
}

Output

Compile error in 0.25.0-RC2 and 0.26.0-bin-20200719-21a90aa-NIGHTLY:

[error] -- Error: /Users/thanhbv/tmp/ex/src/main/scala/C.scala:2:15 --------------------
[error] 2 |  override def size(): Int = super.size()
[error]   |               ^
[error]   |error overriding variable size in class LinkedList of type Int;
[error]   |  method size of type (): Int cannot override final member variable size in class LinkedList

Expectation

Compile successfully as in dotty 0.24.0 & in scala 2

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