Skip to content

Missing requirement: self type does not conform to self type A #2214

Closed
@olafurpg

Description

@olafurpg

The following code snippet compiles with scalac but not with dotc

package squants
trait Quantity[A <: Quantity[A]] { self: A => }
trait TimeDerivative[A <: Quantity[A]] { self: Quantity[_] => }

Dotty reports the error message

-- Error: tests/pos/missing-requirement/Quantity.scala -------------------------
3 |trait TimeDerivative[A <: Quantity[A]] { self: Quantity[_] => }
  |      ^
  |missing requirement: self type squants.Quantity[_] & squants.TimeDerivative[A] of trait TimeDerivative does not conform to self type A' of required trait Quantity
  |
  |where:    A  is a type in trait TimeDerivative with bounds <: squants.Quantity[LazyRef(A)]
  |          A' is a type in trait Quantity with bounds <: squants.Quantity[LazyRef(A)]

Removing the self: Quantity[_] annotation on TimeDerivative removes the error, and makes the rest of the squants project compile with Dotty 🎉

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