The example doesn't compile with 2.13.13 under -Xsource:3-cross (-Xsource-features:infer-override on 2.13.14). The inferred type for final val companion = Editor is taken from the parent.
It compiles with 3.4.1.
trait EditableCellsCompanion {
type Editor <: CellEditor
val Editor: CellEditorCompanion
trait CellEditorCompanion {
type CellInfo
}
trait CellEditor {
val companion: CellEditorCompanion
def componentFor(cellInfo: companion.CellInfo): Object
}
}
sealed trait TreeEditors extends EditableCellsCompanion {
object Editor extends CellEditorCompanion {
class CellInfo
def apply(editor: Editor): Editor = new Editor {
override def componentFor(info: companion.CellInfo): Object = {
editor.componentFor(info)
}
}
}
abstract class Editor extends CellEditor {
final val companion = Editor
// final val companion: Editor.type = Editor
}
}
Maybe it's a bug in Scala 3 though?
Scala 3.4.1 -Vprint:typer:
abstract class Editor() extends Object(), TreeEditors.this.CellEditor {
final val companion: TreeEditors.this.Editor.type = TreeEditors.this.Editor
}
Scala 2.13.13 -Xsource:3-cross -Vprint:typer:
abstract class Editor extends AnyRef with TreeEditors.this.CellEditor {
final <stable> <accessor> def companion: TreeEditors.this.CellEditorCompanion = Editor.this.companion
}
Follow-up for https://github.com/scala/bug/issues/12975.
The example doesn't compile with 2.13.13 under
-Xsource:3-cross
(-Xsource-features:infer-override
on 2.13.14). The inferred type forfinal val companion = Editor
is taken from the parent.It compiles with 3.4.1.
Maybe it's a bug in Scala 3 though?
Scala 3.4.1
-Vprint:typer
:Scala 2.13.13
-Xsource:3-cross -Vprint:typer
: