Skip to content

REPL should report singleton type #17032

Open
@som-snytt

Description

@som-snytt

Compiler version

3.3.1-RC1-bin-SNAPSHOT-git-0df5ae2

Minimized code

Welcome to Scala 3.3.1-RC1-bin-SNAPSHOT-git-0df5ae2 (19, Java OpenJDK 64-Bit Server VM).
Type in expressions for evaluation. Or try :help.

scala> import collection.mutable.ArrayBuffer

scala> val b = new ArrayBuffer[String]
val b: scala.collection.mutable.ArrayBuffer[String] = ArrayBuffer()

scala> b.addOne("hi")
val res0: scala.collection.mutable.ArrayBuffer[String] = ArrayBuffer(hi)

Expectation

Welcome to Scala 2.13.10 (OpenJDK 64-Bit Server VM, Java 19).
Type in expressions for evaluation. Or try :help.

scala> import collection.mutable.ArrayBuffer
import collection.mutable.ArrayBuffer

scala> val b = new ArrayBuffer[String]
val b: scala.collection.mutable.ArrayBuffer[String] = ArrayBuffer()

def addOne(elem: String): b.type

scala> b.addOne("hi")
val res0: b.type = ArrayBuffer(hi)

[The additional output is from tab-complete help.]

Scala 3 res0 should also be b.type. Noticed while reviewing a Scala 2 bug about inferring singleton from overrides.

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