-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fixes to transparent to enable generic tuples #4916
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
Conversation
99ba59c
to
890e83f
Compare
test performance please |
performance test scheduled: 6 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/4916/ to see the changes. Benchmarks is based on merging with master (788908f) |
val tp1 = mapOver { | ||
tp match { | ||
case tp: TypeRef if boundTypes.contains(tp.symbol) => | ||
val TypeAlias(alias) = tp.info |
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.
Can't we get anything other than a TypeAlias
here?
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.
It should always be a TypeAlias
because of the way we generate type bindings. So boundTypes.contains(tp.symbol)
should imply tp.info
is a TypeAlias
.
} | ||
} | ||
val boundVars = getBoundVars(Nil, tpt) | ||
for (bv <- boundVars) ctx.gadt.setBounds(bv, bv.info.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.
This feels a bit ad hoc, isn't there a way to reuse normal type checking of patterns instead of redoing all that work here?
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 tried, but did not find a good way to re-use what's there. it's spread out over several different things.
@@ -165,7 +165,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) { | |||
val leftArg = if (isRightAssoc && isInfixType(l)) "(" ~ argText(l) ~ ")" else argText(l) | |||
val rightArg = if (!isRightAssoc && isInfixType(r)) "(" ~ argText(r) ~ ")" else argText(r) | |||
|
|||
leftArg ~ " " ~ simpleNameString(op.classSymbol) ~ " " ~ rightArg | |||
leftArg ~ " " ~ simpleNameString(op.typeSymbol) ~ " " ~ rightArg |
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.
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.
On rebasing I reverted the conflicting code from #4072. So "("...")" will only be printed if precedence demands it. Not writting redundant parens is important in particular for long sequences of type operators, as for example when working with HLists.
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.
# Conflicts: # tests/run/TupleImpl.scala
A PoC how generic tuples can be implemented - no limit of 22 - generic operations are possible - fully backwards compatible with Scala-2 tuples - specializes for small tuple sizes, yielding optimized code
... to reflect the fact that empty blocks in inline code are now optimized away.
... since they are inlined themselves. Also, fleshed out tuple PoC.
a6b3166
to
103237e
Compare
The newly added test doesn't pass |
Several fixes to transparent methods needed to make the
TupleAbstract.scala
test work. This one is a PoC for an implementation of generic tuples with the following properties: