Skip to content

Specialize Quantity on numeric value #18

@zainab-ali

Description

@zainab-ali

Specializing the quantity would prevent boxing of base numeric types, which unfortunately happens with AnyVal.

However, specialization doesn't seem to play well with singletons and dependent types.
We get the following bizarre error:

[error] /home/zainab/coding/ithaca/libra/src/main/scala/libra/quantity.scala:36: type mismatch;
[error]  found   : a.Out
[error]  required: a.Out
[error]   def add[D1 <: HList](q1: Quantity[A, D1])(implicit a: Add[Quantity[A, D], Quantity[A, D1]]): a.Out = a(this, q1)

Debug logging on the typer phase gives a lot of:

[warn] !!! HK subtype check on [A]collection.this.SeqLike[A,CC[A]] and scala.this.Singleton, but both don't normalize to polytypes:
[warn]   tp1=[A]collection.this.SeqLike[A,CC[A]] PolyType
[warn]   tp2=scala.this.Singleton ClassNoArgsTypeRef

Is this a scalac bug? Is it a feature? Is it a known issue? Any solutions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions