Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-Xsource-features:infer-override stricter than Scala 3 #12980

Open
lrytz opened this issue Apr 4, 2024 · 0 comments
Open

-Xsource-features:infer-override stricter than Scala 3 #12980

lrytz opened this issue Apr 4, 2024 · 0 comments
Milestone

Comments

@lrytz
Copy link
Member

lrytz commented Apr 4, 2024

Follow-up for #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 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
   }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant