Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3b030cf

Browse files
committedNov 17, 2017
Erase unused arguments as if they did not exist in the program
* Addapted all tests * Moved unused argument checks to postyper (for top down traversal with Unused ctx mode). * Removed UnusedArgLift and revert to PhantomArgLift * Disallow user written unused defs and non parameter unused val (temporary)
1 parent 679427b commit 3b030cf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+133
-474
lines changed
 

‎compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,10 @@ class Compiler {
4848
List(new Pickler), // Generate TASTY info
4949
List(new LinkAll), // Reload compilation units from TASTY for library code (if needed)
5050
List(new FirstTransform, // Some transformations to put trees into a canonical form
51-
new UnusedChecks, // Check that unused terms are not used
5251
new CheckReentrant, // Internal use only: Check that compiled program has no data races involving global vars
5352
new ElimJavaPackages), // Eliminate syntactic references to Java packages
5453
List(new CheckStatic, // Check restrictions that apply to @static members
5554
new UnusedRefs, // Removes all calls and references to unused values
56-
new UnusedArgLift, // Extracts the evaluation of unused arguments placing them before the call.
5755
new ElimRepeated, // Rewrite vararg parameters and arguments
5856
new NormalizeFlags, // Rewrite some definition flags
5957
new ExtensionMethods, // Expand methods of value classes with extension methods
@@ -71,7 +69,8 @@ class Compiler {
7169
new ShortcutImplicits, // Allow implicit functions without creating closures
7270
new CrossCastAnd, // Normalize selections involving intersection types.
7371
new Splitter), // Expand selections involving union types into conditionals
74-
List(new UnusedDecls, // Removes all unused defs and vals decls (except for parameters)
72+
List(new PhantomArgLift, // Extracts the evaluation of phantom arguments placing them before the call
73+
new UnusedDecls, // Removes all unused defs and vals decls (except for parameters)
7574
new VCInlineMethods, // Inlines calls to value class methods
7675
new SeqLiterals, // Express vararg arguments as arrays
7776
new InterceptedMethods, // Special handling of `==`, `|=`, `getClass` methods

‎compiler/src/dotty/tools/dotc/core/Mode.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,9 @@ object Mode {
9999

100100
/** We are in the IDE */
101101
val Interactive = newMode(20, "Interactive")
102+
103+
/** We are currently in code that will not be used at runtime.
104+
* It can be in an argument to an unused parameter or a type selection.
105+
*/
106+
val Unused = newMode(21, "Unused")
102107
}

0 commit comments

Comments
 (0)
Please sign in to comment.