Skip to content

Disallow nilary (empty parenthesis) of prefix unary methods #9241

Description

@soronpo

Same as Scala 2 bug scala/bug#12055

Minimized code

class Foo {
  def unary_~() : Foo = this

  // also bad
  def unary_+()(implicit pos: Long): Foo = this
}
val f = new Foo
val f2 = ~f //method unary_~ must be called with () argument

https://scastie.scala-lang.org/NKZQM3d8RrGYRYFoewJyQw

Expectation

Auto-application is disallowed and there a prefix def with a nilary(empty parenthesis) creates an error that cannot be avoided while maintaining a prefix position. To resolve this, we need to deprecate this possibility from the definition site.

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions