Skip to content

Constructor proxy shadowing restriction is a burden in REPL #16700

Open
@som-snytt

Description

@som-snytt

Compiler version

3.2.1

Minimized code

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

scala> case class X(i: Int)
// defined case class X

scala> class X(val i: Int)
// defined class X

scala> X(42)
-- Error: --------------------------------------------------------------------------------------------------------------
1 |X(42)
  |^
  |Reference to constructor proxy for class X
  |shadows outer reference to object X
1 error found

Output

It's similar to the general problem of companionship

scala 2.13.10> class Y; object Y
class Y
object Y

scala 2.13.10> class Y
class Y
warning: previously defined object Y is not a companion to class Y.
Companions must be defined together; you may wish to use :paste mode for this.

except that REPL has no facility for dropping the X term binding.

Expectation

I would like to use constructor proxies in REPL without limitation.

Not sure if REPL is using all history or can selectively ignore the conflicting terms.

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