-
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.
Improve "constructor proxy shadows outer" handling (#17154)
- Loading branch information
Showing
8 changed files
with
167 additions
and
25 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
75 changes: 75 additions & 0 deletions
75
tests/neg-custom-args/explain/constructor-proxy-shadowing.check
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,75 @@ | ||
-- [E177] Reference Error: tests/neg-custom-args/explain/constructor-proxy-shadowing.scala:10:12 ----------------------- | ||
10 | val x = A22("") // error: shadowing | ||
| ^^^ | ||
| Reference to constructor proxy for class A22 in class A | ||
| shadows outer reference to method A22 in object Test | ||
| | ||
| The instance needs to be created with an explicit `new`. | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| There is an ambiguity in the meaning of the call | ||
| | ||
| A22(...) | ||
| | ||
| It could mean creating an instance of class A22 in class A with | ||
| | ||
| new A22(...) | ||
| | ||
| Or it could mean calling method A22 in object Test as in | ||
| | ||
| A22(...) | ||
| | ||
| To disambiguate, use an explicit `new` if you mean the former, | ||
| or use a full prefix for A22 if you mean the latter. | ||
-------------------------------------------------------------------------------------------------------------------- | ||
-- [E177] Reference Error: tests/neg-custom-args/explain/constructor-proxy-shadowing.scala:11:12 ----------------------- | ||
11 | val y = A33("") // error: shadowing | ||
| ^^^ | ||
| Reference to constructor proxy for class A33 in class A | ||
| shadows outer reference to object A33 in object Test | ||
| | ||
| The instance needs to be created with an explicit `new`. | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| There is an ambiguity in the meaning of the call | ||
| | ||
| A33(...) | ||
| | ||
| It could mean creating an instance of class A33 in class A with | ||
| | ||
| new A33(...) | ||
| | ||
| Or it could mean calling the apply method of object A33 in object Test as in | ||
| | ||
| A33.apply(...) | ||
| | ||
| To disambiguate, use an explicit `new` if you mean the former, | ||
| or use a full prefix for A33 if you mean the latter. | ||
-------------------------------------------------------------------------------------------------------------------- | ||
-- [E177] Reference Error: tests/neg-custom-args/explain/constructor-proxy-shadowing.scala:16:8 ------------------------ | ||
16 |val x = Seq(3) // error: shadowing | ||
| ^^^ | ||
| Reference to constructor proxy for class Seq | ||
| shadows outer reference to getter Seq in package scala | ||
| | ||
| The instance needs to be created with an explicit `new`. | ||
|-------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| There is an ambiguity in the meaning of the call | ||
| | ||
| Seq(...) | ||
| | ||
| It could mean creating an instance of class Seq with | ||
| | ||
| new Seq(...) | ||
| | ||
| Or it could mean calling the apply method of getter Seq in package scala as in | ||
| | ||
| Seq.apply(...) | ||
| | ||
| To disambiguate, use an explicit `new` if you mean the former, | ||
| or use a full prefix for Seq if you mean the latter. | ||
-------------------------------------------------------------------------------------------------------------------- |
16 changes: 16 additions & 0 deletions
16
tests/neg-custom-args/explain/constructor-proxy-shadowing.scala
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,16 @@ | ||
|
||
object Test extends App { | ||
def A22(s: String): String = s | ||
class A33(s: String) | ||
object A33: | ||
def apply(s: String) = ??? | ||
class A { | ||
class A22(s: String) | ||
class A33(s: String) | ||
val x = A22("") // error: shadowing | ||
val y = A33("") // error: shadowing | ||
} | ||
} | ||
|
||
class Seq(n: Int) | ||
val x = Seq(3) // error: shadowing |
This file was deleted.
Oops, something went wrong.
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,7 @@ | ||
class Number(n: Int) | ||
val x = Number(3) | ||
|
||
class Seq(n: Int) | ||
val y = Seq | ||
|
||
|