Skip to content

Overriding method returning this type in final class from TASTy #9994

Closed
@nicolasstucki

Description

@nicolasstucki

Full Reproduction

$ mkdir out/testStringBuilderFromTasty
$ sbt
sbt:dotty> dotty-bootstrapped/dotc -d out/testStringBuilderFromTasty community-build/community-projects/stdLib213/src/library/scala/collection/mutable/StringBuilder.scala
sbt:dotty> dotty-bootstrapped/dotc -from-tasty -classpath out/testStringBuilderFromTasty scala.collection.mutable.StringBuilder
...
-- Error: community-build/community-projects/stdLib213/src/library/scala/collection/mutable/StringBuilder.scala:87:6 
87 |  def addOne(x: Char): this.type = { underlying.append(x); this }
   |      ^
   |error overriding method addOne in trait Growable of type (elem: Char): (StringBuilder.this : StringBuilder);
   |  method addOne of type (x: Char): (StringBuilder.this : StringBuilder) has incompatible type

Minimized Reproduction

Bar.scala

trait Foo:
  def foo: this.type

final class Bar extends Foo:
  def foo: this.type = this
$ mkdir out/test
$ sbt
sbt:dotty> dotty-bootstrapped/dotc StringBuilder.scala -d out/test
sbt:dotty> dotty-bootstrapped/dotc -from-tasty -classpath out/test Bar

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions