-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Check implicitNotFound annotations for invalid type variable references #9430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
smarter
merged 1 commit into
scala:master
from
YourPsychiatrist:check-implicit-annot-refs
Aug 7, 2020
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,40 @@ | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:5:56 --------------------------------------- | ||
5 |@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // error | ||
| ^ | ||
| Invalid reference to a type variable "B" found in the annotation argument. | ||
| The variable does not occur in the signature of ShouldWarn1. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:9:56 --------------------------------------- | ||
9 |@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // error | ||
| ^ | ||
| Invalid reference to a type variable "A" found in the annotation argument. | ||
| The variable does not occur in the signature of ShouldWarn2. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:13:56 -------------------------------------- | ||
13 |@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // error | ||
| ^ | ||
| Invalid reference to a type variable "A" found in the annotation argument. | ||
| The variable does not occur in the signature of ShouldWarn3. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:17:56 -------------------------------------- | ||
17 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error | ||
| ^ | ||
| Invalid reference to a type variable "A" found in the annotation argument. | ||
| The variable does not occur in the signature of ShouldWarn4. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:17:61 -------------------------------------- | ||
17 |@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error | ||
| ^ | ||
| Invalid reference to a type variable "B" found in the annotation argument. | ||
| The variable does not occur in the signature of ShouldWarn4. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:21:61 -------------------------------------- | ||
21 |@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // error | ||
| ^ | ||
| Invalid reference to a type variable "Abc" found in the annotation argument. | ||
| The variable does not occur in the signature of ShouldWarn5. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:44:54 -------------------------------------- | ||
44 |class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // error | ||
| ^ | ||
| Invalid reference to a type variable "B" found in the annotation argument. | ||
| The variable does not occur in the signature of the constructor. | ||
-- [E158] Reference Error: tests/neg-custom-args/fatal-warnings/i4008.scala:46:62 -------------------------------------- | ||
46 |def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // error | ||
| ^ | ||
| Invalid reference to a type variable "B" found in the annotation argument. | ||
| The variable does not occur in the signature of someMethod1. |
This file contains hidden or 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,48 @@ | ||
// ===== Template annotations ===== | ||
|
||
|
||
// class, 1TP, invalid ref | ||
@annotation.implicitNotFound("An implicit ShouldWarn1[${B}] is not in scope") // error | ||
class ShouldWarn1[A] | ||
|
||
// trait, 1TP, invalid ref | ||
@annotation.implicitNotFound("An implicit ShouldWarn2[${A}] is not in scope") // error | ||
trait ShouldWarn2[B] | ||
|
||
// trait, 2TP, 1 invalid ref | ||
@annotation.implicitNotFound("An implicit ShouldWarn3[${A},${B}] is not in scope") // error | ||
trait ShouldWarn3[B, C] | ||
|
||
// class, 2TP, 2 invalid refs | ||
@annotation.implicitNotFound("An implicit ShouldWarn4[${A},${B}] is not in scope") // error // error | ||
class ShouldWarn4[C, D] | ||
|
||
// class, 2TP, 1 invalid multi-char refs | ||
@annotation.implicitNotFound("An implicit ShouldWarn5[${C},${Abc}] is not in scope") // error | ||
class ShouldWarn5[C, D] | ||
|
||
// trait, 1TP, valid ref | ||
@annotation.implicitNotFound("An implicit ShouldntWarn1[${A}] is not in scope") | ||
trait ShouldntWarn1[A] | ||
|
||
// class, 2TP, only one ref but that one is valid | ||
@annotation.implicitNotFound("An implicit ShouldntWarn2[${A}, ...] is not in scope") | ||
class ShouldntWarn2[A, B] | ||
|
||
// trait, 2TP, 2 valid refs | ||
@annotation.implicitNotFound("An implicit ShouldntWarn3[${A}, ${B}] is not in scope") | ||
trait ShouldntWarn3[A, B] | ||
|
||
// class, 2TP, 2 valid refs | ||
@annotation.implicitNotFound("An implicit ShouldntWarn4[${Hello},${World}] is not in scope") | ||
class ShouldntWarn4[Hello, World] | ||
|
||
// ===== DefDef param annotations ===== | ||
|
||
|
||
@annotation.implicitNotFound("Hopefully you don't see this!") | ||
class C[A](using @annotation.implicitNotFound("No C[${B}] found") c: Class[A]) // error | ||
|
||
def someMethod1[A](using @annotation.implicitNotFound("No C[${B}] found") sc: C[A]) = 0 // error | ||
|
||
def someMethod2[A](using @annotation.implicitNotFound("No C[${A}] found") sc: C[A]) = "" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.