Skip to content

Parser error resulting in "overloaded or recursive method needs return type" #3737

Closed
@soronpo

Description

@soronpo

I also created a scastie link with the code.

object Main {
  def main(args: Array[String]) = println("")

  object Foo {
    def apply(t : Any)(block: => Unit) : Unit = {}
    def foo(t : Any)(block: => Unit) : Unit = {}
  }

  object Test {
    Foo(1){} //OK
    Foo.foo(1) {} //OK
    Foo foo(1) {} //overloaded or recursive method  needs return type
  }
}

Using -Xprint:parser, gives the following:

    parsed:
    package  {
      module object Main extends { 
         def main( args: Array[String]) = println("")
        module object Foo extends { 
           def apply( t: Any)( block: => Unit): Unit = 
            {
              
            }
           def foo( t: Any)( block: => Unit): Unit = 
            {
              
            }
        }
        module object Test extends { 
          Foo(1)(
            {
              
            }
          )
          Foo.foo(1)(
            {
              
            }
          )
          Foo foo 
            (1)(
              {
                
              }
            )
        }
      }
    }

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