-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Implement inline #1492
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
Implement inline #1492
Changes from all commits
Commits
Show all changes
77 commits
Select commit
Hold shift + click to select a range
56f01cd
Namer refactoing
odersky c87a9dd
First version of inline scheme
odersky d63a6ba
Make Context#moreProperties strongly typed
odersky 8a3762a
Add Inlined tree node
odersky faba2b7
Track Inlined nodes in ctx.source
odersky 617be51
Print inlining positions in error messages
odersky 729815b
Implement inline if
odersky b8a1176
Avoid simple aliases in bindings
odersky 6f9f29e
Recursive inlining tests
odersky a75fee2
Don't expand stat before recursion in namer
felixmulder fd7b60c
Fix stack overflow on recurs in namer
felixmulder a47a800
Simplify enclosingInlineds
odersky 96d0573
Support separate compilation
odersky 688cc89
Add check files
odersky 333ec27
Set the positions of inlined trees wehn read form Tasty
odersky c1674dc
Neg test demonstrating inline positions under cross-compilation
odersky a81070c
Fix some problems in Inliner
odersky 379bb24
Remove redundanr test
odersky be53234
Add comment missing from last PR
odersky 9a48e7b
Don't inline after typer.
odersky 7cce2d4
Harden Inliner.sourceFile
odersky 0bd955e
Drop Inlined when homogenize
odersky 1d93264
Handle outer this in Inliner
odersky ba6bc75
Add test for pattern matching against outer
odersky b84bcbf
Update check file
odersky 29acee0
Move InlineTyper to Inliner class
odersky 4dd8469
Avoid reference to local bindings in Inlined nodes
odersky 3354557
Fix bugs related to type parameter remapping
odersky ebcc2bd
Fix problem with homogenize trees
odersky 61e8ea4
Better diagnostics for TreeChecker
odersky 04de4b5
Fix problems handling types in Inliner
odersky 5396a6b
Better error message in TreePickler
odersky 5a345e7
Inline key operations in dotty
odersky 60b6c6a
Harden ReTyper so that it's fit for inlining
odersky d96cb84
Test case for closure inlining
odersky bd0660e
Juggling with close in RefinedPrinter
odersky 19ab7ab
Make inline annotation @scala.inline.
odersky f8d7500
Fix problem affecting recursive inlines
odersky 7f3b9ca
Handle Inlined blocks on ElimErasedValueType
odersky aa4d49d
Suppress inlining printing
odersky b538f84
Suppress inline in dottydoc test of standard library
odersky 4253578
Better toString for TermRefWithSig
odersky bf3345a
Fix ExplicitSelf phase
odersky ae67c35
Add accessors for non-public members accessed from inline methods
odersky c9e45de
Support access for setting private vars from inlined code
odersky b1cda4f
Better names and documentation for Inliner.
odersky 184296f
Inline argument closures to inline methods
odersky d1b933c
Fix bug in InlineableClosure
odersky 6bf7768
Refactoring for registering InlineInfo
odersky 8e66f53
More inline tests
odersky e93b7bf
Don't add inline accessors twice
odersky d575e58
Make inline a keyword
odersky b743a9b
Make inline methods and field effectively final
odersky 975d297
Fix problem related to accessor generation under separate compilation
odersky b559aff
Add accessibility check for type of new
odersky 845b689
Add inline for vals
odersky 7537cfc
Document deviations from inline SIP
odersky 4de907a
Always use implicit context at the current period
odersky 65551d1
Don't drop inline closure bindings that are referred in the body
odersky 84bc770
Drop annotations from dealias
odersky b5132e8
Change owner as necessary when typing a TypedSplice
odersky 748d1d8
Generalize checkInlineConformant to functions
odersky c9fa504
Inline function parameters
odersky 5a46d19
Handle inlining in inlining arguments
odersky 95e488e
Use BodyAnnot to indicate rhs of inline method
odersky ce9efda
Add check file
odersky bef012d
Move logic from InlineInfo to BodyAnnot
odersky 53b165e
Cleanups
odersky eb95a04
Remove incorrect special case for Inline purity checks
smarter f239bdb
Disable scaladoc generation for dotty
smarter d4f0069
Fix incremental compilation when inline method signature changes
smarter 6821bac
Fix incremental compilation when inline method body changes
smarter e5119a0
Address @smarter's review comments
odersky e795437
Fix inline failure in the presence of unit conversion
odersky 0093c5d
Add test case
odersky 215b97c
DottyBytecodeTest: fix diffInstructions output
smarter e0a14e7
Add InlineBytecodeTests to check that inline really works
smarter 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
object A { | ||
def get: Int = 1 | ||
} |
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,5 @@ | ||
object C { | ||
def main(args: Array[String]): Unit = { | ||
val i: Int = B.getInline | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
bridge/src/sbt-test/source-dependencies/inline/changes/B1.scala
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,4 @@ | ||
object B { | ||
@inline def getInline: Int = | ||
A.get | ||
} |
4 changes: 4 additions & 0 deletions
4
bridge/src/sbt-test/source-dependencies/inline/changes/B2.scala
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,4 @@ | ||
object B { | ||
@inline def getInline: Double = | ||
A.get | ||
} |
4 changes: 4 additions & 0 deletions
4
bridge/src/sbt-test/source-dependencies/inline/changes/B3.scala
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,4 @@ | ||
object B { | ||
@inline def getInline: Int = | ||
sys.error("This is an expected failure when running C") | ||
} |
17 changes: 17 additions & 0 deletions
17
bridge/src/sbt-test/source-dependencies/inline/project/DottyInjectedPlugin.scala
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,17 @@ | ||
import sbt._ | ||
import Keys._ | ||
|
||
object DottyInjectedPlugin extends AutoPlugin { | ||
override def requires = plugins.JvmPlugin | ||
override def trigger = allRequirements | ||
|
||
override val projectSettings = Seq( | ||
scalaVersion := "0.1-SNAPSHOT", | ||
scalaOrganization := "ch.epfl.lamp", | ||
scalacOptions += "-language:Scala2", | ||
scalaBinaryVersion := "2.11", | ||
autoScalaLibrary := false, | ||
libraryDependencies ++= Seq("org.scala-lang" % "scala-library" % "2.11.5"), | ||
scalaCompilerBridgeSource := ("ch.epfl.lamp" % "dotty-bridge" % "0.1.1-SNAPSHOT" % "component").sources() | ||
) | ||
} |
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,14 @@ | ||
$ copy-file changes/B1.scala B.scala | ||
> compile | ||
|
||
$ copy-file changes/B2.scala B.scala | ||
# Compilation of C.scala should fail because B.getInline now has type Double instead of Int | ||
-> compile | ||
|
||
$ copy-file changes/B1.scala B.scala | ||
> run | ||
|
||
$ copy-file changes/B3.scala B.scala | ||
# The body of B.getInline was changed so C.scala should be recompiled | ||
# If it was recompiled, run should fail since B.getInline now throws an exception | ||
-> run |
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,8 @@ | ||
package dotty.annotation.internal | ||
|
||
import scala.annotation.Annotation | ||
|
||
/** The class associated with a `BodyAnnotation`, which indicates | ||
* an inline method's right hand side | ||
*/ | ||
final class Body() extends Annotation |
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,6 @@ | ||
package dotty.annotation.internal | ||
|
||
import scala.annotation.Annotation | ||
|
||
/** An annotation produced by Namer to indicate an inline parameter */ | ||
final class InlineParam() extends Annotation |
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
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
Oops, something went wrong.
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.
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 is only correct for closures created by
desugar.makeClosure
and only for certain phases, we have similar pattern matches in other places that makes similar assumption and I don't like it either, I thinkExpandSAMs#transformBlock
is the only one which tries to be careful, maybe we could use that 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.
Not sure about this one. The question is, how should closures in other blocks be categorized? Is that still a closure or something else? For the moment I'd leave as is.