Skip to content

Calling case class constructor without apply fails #4466

@Arthurm1

Description

@Arthurm1
object Foo {
  case class Bar(map: Map[String, String]) 

  object Bar {
    def apply(str: String): Bar = ???
  }

  Bar(Map("A" -> "B"))
}

gives

-- [E050] Reference Error: /tmp/scastie7649626593689591865/src/main/scala/main.scala:8:2 
8 |  Bar(Map("A" -> "B"))
  |  ^^^
  |  object Bar in object Foo does not take parameters

works if using apply

  Bar.apply(Map("A" -> "B"))

works without companion object

object Foo {
  case class Bar(map: Map[String, String]) 

  Bar(Map("A" -> "B"))
}

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