-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn universal extensions on opaque types (#22502)
Fixes #22232 Work also done by @hamzaremmal, @julian-a-avar-c and @nmcb Co-authored-by: Hamza Remmal <hamza@remmal.net>
- Loading branch information
1 parent
9450855
commit 7d79c56
Showing
3 changed files
with
62 additions
and
2 deletions.
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,28 @@ | ||
-- [E194] Potential Issue Warning: tests/warn/i22232.scala:3:23 -------------------------------------------------------- | ||
3 | extension (c: C) def equals(that: Any): Boolean = false // warn | ||
| ^ | ||
| Extension method equals will never be selected from type C | ||
| because C already has a member with the same name and compatible parameter types. | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E194] Potential Issue Warning: tests/warn/i22232.scala:9:25 -------------------------------------------------------- | ||
9 | extension (d: D) def equals(that: Any): Boolean = false // warn | ||
| ^ | ||
| Extension method equals will never be selected from type C | ||
| because C already has a member with the same name and compatible parameter types. | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E194] Potential Issue Warning: tests/warn/i22232.scala:13:38 ------------------------------------------------------- | ||
13 | extension (arr: MyString[Byte]) def length: Int = 0 // warn | ||
| ^ | ||
| Extension method length will never be selected from type String | ||
| because String already has a member with the same name and compatible parameter types. | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E194] Potential Issue Warning: tests/warn/i22232.scala:17:46 ------------------------------------------------------- | ||
17 | extension [T <: MyString[Byte]](arr: T) def length: Int = 0 // warn | ||
| ^ | ||
| Extension method length will never be selected from type String | ||
| because String already has a member with the same name and compatible parameter types. | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,32 @@ | ||
class C | ||
object C: | ||
extension (c: C) def equals(that: Any): Boolean = false // warn | ||
|
||
object X: | ||
class C | ||
opaque type D <: C = C | ||
object D: | ||
extension (d: D) def equals(that: Any): Boolean = false // warn | ||
|
||
object Upperbound1: | ||
opaque type MyString[+T] <: String = String | ||
extension (arr: MyString[Byte]) def length: Int = 0 // warn | ||
|
||
object Upperbound2: | ||
opaque type MyString[+T] <: String = String | ||
extension [T <: MyString[Byte]](arr: T) def length: Int = 0 // warn | ||
|
||
object Upperbound3: | ||
opaque type MyString[+T] <: String = String | ||
extension [T](arr: T) def length: Int = 0 // nowarn | ||
|
||
object NonUpperbound1: | ||
opaque type MyString[+T] = String | ||
extension (arr: MyString[Byte]) def length: Int = 0 // nowarn | ||
object NonUpperbound2: | ||
opaque type MyString[+T] = String | ||
extension [T <: MyString[Byte]](arr: T) def length2: Int = 0 // nowarn | ||
|
||
object NonUpperbound3: | ||
opaque type MyString[+T] = String | ||
extension [T](arr: T) def length: Int = 0 // nowarn |