forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn on unary methods with parameters
Fixes scala#9241
- Loading branch information
1 parent
1d83d0f
commit e5ecf14
Showing
2 changed files
with
84 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
class Foo { | ||
def unary_~() : Foo = this // error | ||
def unary_-(using Int)(): Foo = this // error | ||
def unary_+()(implicit i: Int): Foo = this // error | ||
def unary_![T](): Foo = this // error | ||
} | ||
|
||
class Bar { | ||
def unary_~ : Bar = this | ||
def unary_-(using Int): Bar = this | ||
def unary_+(implicit i: Int): Bar = this | ||
def unary_![T]: Bar = this | ||
} | ||
|
||
final class Baz private (val x: Int) extends AnyVal { | ||
def unary_- : Baz = ??? | ||
def unary_+[T] : Baz = ??? | ||
def unary_!() : Baz = ??? // error | ||
def unary_~(using Int) : Baz = ??? | ||
} | ||
|
||
extension (x: Int) | ||
def unary_- : Int = ??? | ||
def unary_+[T] : Int = ??? | ||
def unary_!() : Int = ??? // error | ||
def unary_~(using Int) : Int = ??? | ||
end extension | ||
|
||
extension [T](x: Short) | ||
def unary_- : Int = ??? | ||
def unary_+[U] : Int = ??? | ||
def unary_!() : Int = ??? // error | ||
def unary_~(using Int) : Int = ??? | ||
end extension | ||
|
||
extension (using Int)(x: Byte) | ||
def unary_- : Int = ??? | ||
def unary_+[U] : Int = ??? | ||
def unary_!() : Int = ??? // error | ||
def unary_~(using Int) : Int = ??? | ||
end extension |