Skip to content

Fix synthetic type bounds in Tasty reflect #4601

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
merged 4 commits into from
Jun 14, 2018

Conversation

nicolasstucki
Copy link
Contributor

No description provided.

@nicolasstucki nicolasstucki self-assigned this May 30, 2018
@nicolasstucki nicolasstucki changed the title Fix synthetic type bounds Fix synthetic type bounds in Tasty reflect May 30, 2018
@nicolasstucki nicolasstucki force-pushed the fix-synthetic-type-bounds branch 2 times, most recently from bd4254b to 19a069c Compare May 31, 2018 12:10
@nicolasstucki nicolasstucki force-pushed the fix-synthetic-type-bounds branch 3 times, most recently from 03403b4 to 3d3dbb6 Compare June 9, 2018 19:41
To represent dotty TypeTrees containing type bounds
@nicolasstucki nicolasstucki force-pushed the fix-synthetic-type-bounds branch from 8b5f22d to a83f019 Compare June 11, 2018 19:28
In dotty bootstapped the assert is inlined
Copy link
Contributor

@liufengyun liufengyun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise, LGTM

@@ -538,7 +538,7 @@ object TastyImpl extends scala.tasty.Tasty {

object Synthetic extends SyntheticExtractor {
def unapply(x: TypeTree)(implicit ctx: Context): Boolean = x match {
case Trees.TypeTree() => true
case x @ Trees.TypeTree() => !x.tpe.isInstanceOf[Types.TypeBounds]
case _ => false
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the name synthetic, I cannot justify the change. Maybe a doc for Synthetic, I naively assume synthetic bounds are also synthetic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will add some documentation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added

@@ -188,7 +190,8 @@ class ShowExtractors[T <: Tasty with Singleton](tasty0: T) extends Show[T](tasty
case Type.PolyType(argNames, argBounds, resType) =>
this += "Type.PolyType(" ++= argNames += ", " ++= argBounds += ", " += resType += ")"
case Type.TypeLambda(argNames, argBounds, resType) =>
this += "Type.TypeLambda(" ++= argNames += ", " ++= argBounds += ", " += resType += ")"
// resType is not printed to avoid cycles
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious what kind of cycles can happen here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For definitions, we use the tree of the definition. Somewhere in the body of the type lambda there was a reference to itself and then tried to reprint itself in a loop.

@nicolasstucki nicolasstucki merged commit 76b110b into scala:master Jun 14, 2018
@allanrenucci allanrenucci deleted the fix-synthetic-type-bounds branch June 14, 2018 07:11
odersky pushed a commit to dotty-staging/dotty that referenced this pull request Jun 23, 2018
…ounds

Fix synthetic type bounds in Tasty reflect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants