Skip to content

Singleton types are lost when used on the left of a right-associative operator #10726

Closed
@hrhino

Description

@hrhino

From gitter a few days back:

Welcome to Scala 2.13.0-M3 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_121).
Type in expressions for evaluation. Or try :help.

scala> def nom(foods: List["food"]): Unit = println("yum!")
nom: (foods: List["food"])Unit

scala> nom("food" :: Nil)
                  ^
       error: type mismatch;
        found   : rassoc$1.type (with underlying type String)
        required: "food"

scala> nom(Nil.::("food"))
yum!

The temporary ValDef that "food" is put in during desugaring gets typed with the widened String, rather than "food".

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions