-
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.
Have a better error message when healing types (#21711)
Closes #21696
- Loading branch information
Showing
6 changed files
with
56 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- [E202] Staging Issue Error: tests/neg/i21696.scala:7:52 ------------------------------------------------------------- | ||
7 |def foo[T](using Quotes): Expr[Thing[T]] = '{ Thing[T]() } // error | ||
| ^ | ||
| Reference to T within quotes requires a given scala.quoted.Type[T] in scope | ||
|--------------------------------------------------------------------------------------------------------------------- | ||
| Explanation (enabled by `-explain`) | ||
|- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - | ||
| Referencing `T` inside a quoted expression requires a `scala.quoted.Type[T]` to be in scope. | ||
| Since Scala is subject to erasure at runtime, the type information will be missing during the execution of the code. | ||
| `scala.quoted.Type[T]` is therefore needed to carry `T`'s type information into the quoted code. | ||
| Without an implicit `scala.quoted.Type[T]`, the type `T` cannot be properly referenced within the expression. | ||
| To resolve this, ensure that a `scala.quoted.Type[T]` is available, either through a context-bound or explicitly. | ||
--------------------------------------------------------------------------------------------------------------------- |
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 @@ | ||
//> using options -explain | ||
|
||
import scala.quoted.{Expr, Quotes} | ||
|
||
case class Thing[T]() | ||
|
||
def foo[T](using Quotes): Expr[Thing[T]] = '{ Thing[T]() } // error |