-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Move inline β-reduction out of typer #5216
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
odersky
merged 17 commits into
scala:master
from
dotty-staging:move-inline-out-of-typer
Oct 22, 2018
Merged
Changes from 14 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6acaf31
Move inline β-reduction out of typer
nicolasstucki 017edbd
Fix `this` bindings for ExprType
nicolasstucki 9aa3811
Temporarily disable 2 tests
nicolasstucki 432eb0a
Move inline β-reduction after post typer
nicolasstucki 746fdd7
Normalize call at Inlined node creation
nicolasstucki c68dc1f
Move inline β-reduction after Pickler
nicolasstucki 32c8798
Fix constant folding during inlining
nicolasstucki da0c249
Add a bit of documentation
nicolasstucki 927ae4e
Check if unpickled tree has inline nodes
nicolasstucki c6c5389
Fix tuples inlining
nicolasstucki 9e14dee
Fix dependent function type test
nicolasstucki f28e2e1
Only run InlineCalls if the tree contains an inline call
nicolasstucki 0832e02
Update doc
nicolasstucki 894ecee
Update comment
nicolasstucki 72f3ab6
Fix typo
nicolasstucki 954c25b
Add isInlineCall to TreeInfo
nicolasstucki c12e875
Erase rhs of erased non inlined val/def in PostTyper
nicolasstucki 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
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,45 @@ | ||
package dotty.tools.dotc.transform | ||
|
||
import dotty.tools.dotc.ast.Trees._ | ||
import dotty.tools.dotc.ast.tpd | ||
import dotty.tools.dotc.core.Contexts._ | ||
import dotty.tools.dotc.core.Phases.Phase | ||
import dotty.tools.dotc.core.Types.MethodicType | ||
import dotty.tools.dotc.transform.SymUtils._ | ||
import dotty.tools.dotc.typer.{ConstFold, Inliner} | ||
|
||
/** β-reduce all calls to inline methods and preform constant folding */ | ||
nicolasstucki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
class InlineCalls extends MacroTransform { thisPhase => | ||
import tpd._ | ||
|
||
override def phaseName: String = InlineCalls.name | ||
|
||
override def run(implicit ctx: Context): Unit = | ||
if (ctx.compilationUnit.containsInlineCalls && !ctx.settings.YnoInline.value) super.run | ||
nicolasstucki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
override def transformPhase(implicit ctx: Context): Phase = thisPhase.next | ||
|
||
protected def newTransformer(implicit ctx: Context): Transformer = | ||
new InlineCallsTransformer | ||
|
||
class InlineCallsTransformer extends Transformer { | ||
override def transform(tree: Tree)(implicit ctx: Context): Tree = tree match { | ||
case _: RefTree | _: GenericApply[_] if !tree.tpe.widenDealias.isInstanceOf[MethodicType] && Inliner.isInlineable(tree) && !ctx.reporter.hasErrors => | ||
nicolasstucki marked this conversation as resolved.
Show resolved
Hide resolved
|
||
val tree2 = super.transform(tree) // transform arguments before inlining (inline arguments and constant fold arguments) | ||
transform(Inliner.inlineCall(tree2, tree.tpe.widen)) | ||
case _: MemberDef => | ||
val newTree = super.transform(tree) | ||
newTree.symbol.defTree = newTree // update tree set in PostTyper or set for inlined members | ||
newTree | ||
case _ => | ||
if (tree.symbol.isQuote || tree.symbol.isSplice) | ||
ctx.compilationUnit.containsQuotesOrSplices = true | ||
ConstFold(super.transform(tree)) | ||
} | ||
} | ||
|
||
} | ||
|
||
object InlineCalls { | ||
final val name = "inlineCalls" | ||
} |
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
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,9 @@ | ||
object Test extends App { | ||
val t7 = '5' *: 4 *: "C" *: () | ||
|
||
val t7a = t7.tail | ||
val t7b = t7a.tail | ||
val t7c: Unit = (t7.tail: (Int, String)).tail | ||
val t7d: Unit = (t7.tail: Int *: String *: Unit).tail | ||
val t7e: Unit = t7.tail.tail | ||
} |
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.