Skip to content

new-less object construction does not work on secondary constuctors #7217

Closed
@aappddeevv

Description

@aappddeevv

I was calling the new-less object secondary constructor but it would not work without using new.

Boiled down example from my code:

class Foo(p1: String, p2: String):
  def this(p1: String) = this(p1, "blah")

val x = Foo("blah", "hah")
val y = Foo("blah")

I needed to add new Foo("blah") to get y to compile.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions