-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add missing case for SyntheticBounds #5475
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
Add missing case for SyntheticBounds #5475
Conversation
@@ -98,6 +98,7 @@ trait TreeUtils | |||
case TypeTree.ByName(result) => foldTypeTree(x, result) | |||
case TypeTree.Annotated(arg, annot) => foldTree(foldTypeTree(x, arg), annot) | |||
case TypeBoundsTree(lo, hi) => foldTypeTree(foldTypeTree(x, lo), hi) | |||
case SyntheticBounds() => x |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is SyntheticBounds
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Internally it is a TypeTree
that has a type bound. We needed two different extractors Synthetic
/SyntheticBounds
as we differentiate separate abstract types for types and type bounds.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean a "type" of the form _ >: L <: U
? If yes, should it be called WildcardType
then? SyntheticBounds
tells me not a lot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is for wildcards but aslo for some synthetic bounds.
After some exploration I discovered that the second case only apears with enums. It looks like we generate some type parameter bounds as a TypeTree
wheras all other cases are in a TypeBoundsTree
.
I will rename it to WildcardType
and move the other case to TypeBoundsTree
.
@nicolasstucki The CI is not happy. |
7708510
to
c4b52a0
Compare
@liufengyun the CI is happy again. |
906796e
to
15ab19c
Compare
15ab19c
to
12e0e3e
Compare
Rebased |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -311,6 +311,9 @@ trait Core { | |||
/** Type tree representing a type bound written in the source */ | |||
type TypeBoundsTree <: TypeOrBoundsTree | |||
|
|||
/** Type tree representing wildcard type bounds written in the source */ | |||
type WildcardType <: TypeOrBoundsTree | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the document is not precise. Given the following code:
val a: List[_] = List(1, "String")
The underscore become TypeBoundsTree(TypeTree( | scala.this.Nothing), TypeTree( | scala.this.Any) | )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can give the hypothesis in #5483 a second thought.
Even if we want to report errors for type trees:
- it's completely acceptable for end users to see the error report on the whole type tree
- they work for type alias and infered types as well
- In practice, I conjecture that macro authors will check types to detect errors, and then just report errors on the whole type tree instead of inspecting the components of type trees & deal with inferred and aliased types.
fooMacro[List[Int]]
^^^
No description provided.