-
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 if extension receiver already has member (#17543)
Best effort to warn if defining extension method for a type which has a non-private member of the same name and a subsuming signature. Excludes opaque types (for defining forwarders to a public API) and other alias types (where the type member may override an abstract type member). Fixes #16743
- Loading branch information
Showing
13 changed files
with
315 additions
and
36 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
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
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
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
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ package tests | |
package inheritedMembers1 | ||
|
||
|
||
/*<-*/@annotation.nowarn/*->*/ | ||
class A | ||
{ | ||
def A: String | ||
|
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,84 @@ | ||
-- [E194] Potential Issue Warning: tests/warn/i16743.scala:30:6 -------------------------------------------------------- | ||
30 | def t = 27 // warn | ||
| ^ | ||
| Extension method t will never be selected | ||
| because T 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/i16743.scala:32:6 -------------------------------------------------------- | ||
32 | def g(x: String)(i: Int): String = x*i // warn | ||
| ^ | ||
| Extension method g will never be selected | ||
| because T 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/i16743.scala:33:6 -------------------------------------------------------- | ||
33 | def h(x: String): String = x // warn | ||
| ^ | ||
| Extension method h will never be selected | ||
| because T 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/i16743.scala:35:6 -------------------------------------------------------- | ||
35 | def j(x: Any, y: Int): String = (x.toString)*y // warn | ||
| ^ | ||
| Extension method j will never be selected | ||
| because T 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/i16743.scala:36:6 -------------------------------------------------------- | ||
36 | def k(x: String): String = x // warn | ||
| ^ | ||
| Extension method k will never be selected | ||
| because T 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/i16743.scala:38:6 -------------------------------------------------------- | ||
38 | def m(using String): String = "m" + summon[String] // warn | ||
| ^ | ||
| Extension method m will never be selected | ||
| because T 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/i16743.scala:39:6 -------------------------------------------------------- | ||
39 | def n(using String): String = "n" + summon[String] // warn | ||
| ^ | ||
| Extension method n will never be selected | ||
| because T 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/i16743.scala:40:6 -------------------------------------------------------- | ||
40 | def o: String = "42" // warn | ||
| ^ | ||
| Extension method o will never be selected | ||
| because T 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/i16743.scala:41:6 -------------------------------------------------------- | ||
41 | def u: Int = 27 // warn | ||
| ^ | ||
| Extension method u will never be selected | ||
| because T 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/i16743.scala:44:6 -------------------------------------------------------- | ||
44 | def at: Int = 42 // warn | ||
| ^ | ||
| Extension method at will never be selected | ||
| because T 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/i16743.scala:46:6 -------------------------------------------------------- | ||
46 | def x(using String)(n: Int): Int = summon[String].toInt + n // warn | ||
| ^ | ||
| Extension method x will never be selected | ||
| because T 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/i16743.scala:47:6 -------------------------------------------------------- | ||
47 | def y(using String)(s: String): String = s + summon[String] // warn | ||
| ^ | ||
| Extension method y will never be selected | ||
| because T already has a member with the same name and compatible parameter types. | ||
| | ||
| longer explanation available when compiling with `-explain` |
Oops, something went wrong.