aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/ast/TreeInfo.scala
Commit message (Collapse)AuthorAgeFilesLines
* Address @smarter's review commentsMartin Odersky2016-10-021-1/+1
|
* Remove incorrect special case for Inline purity checksGuillaume Martres2016-10-021-2/+1
| | | | | | | | | This special case was added two years ago, quoting from 5428549a57b710b11e57aab4eee24e9b89b8b97c "Inlined pure values are pure even if referenced from impure prefixes (i.e. prefix need not be evaluated)" This does not match the current semantics for inline where the prefix is always evaluated.
* Generalize checkInlineConformant to functionsMartin Odersky2016-10-021-1/+4
| | | | | | | | Pure expressions with function types now are considered conforming. Necessitated a change in TreeInfo to accept closures as pure expressions. Test case in inlineForeach
* Don't drop inline closure bindings that are referred in the bodyMartin Odersky2016-10-021-6/+16
| | | | | The body might still refer to an inline closure argument without fully applying it. In that case the binding may not be dropped.
* Add accessors for non-public members accessed from inline methodsMartin Odersky2016-10-021-0/+14
| | | | | | | | This makes existsing uses of inline mostly compile. Todo: Verify that stdlib can be compiled. Todo: Implement accessors for assignments to priavte variables Todo: Figure out what to do with accesses to private types.
* Drop tpd.modsDecoMartin Odersky2016-09-261-13/+14
| | | | Prefer to access directly via symbol.
* Get rid of SelectFromType tree node.Martin Odersky2016-09-251-1/+1
| | | | | | Roll its functionality into Select. Since we can always tell whether a tree is a type or term there is no expressiveness gained by having a separate tree node.
* Swap order of elements in AnnotatedMartin Odersky2016-09-241-1/+1
| | | | | | | | | Now it's annotated first, annotation second. This is in line with AnnotatedType and in line with the principle that tree arguments should come in the order they are written. The reason why the order was swapped before is historical - Scala2 did it that way.
* Make positions fit for metaMartin Odersky2016-09-241-1/+1
| | | | | | | | | | | | | | | | | | In particular: - get rid of envelope, it's too complicated and hides too many errors - check that everywhere in parsed trees the position range of a parent node contains the position ranges of its children. - check that all non-empty trees coming from parser have positions. The commit contains lots of fixes to make these checks pass. In particular, it changes the scheme how definitions are positioned. Previously the position of a definition was the token range of the name defined by it. That does obviously not work with the parent/children invariant. Now, the position is the whole definition range, with the point at the defined name (care is taken to not count backticks). Namer is changed to still use the token range of defined name as the position of the symbol.
* Fix #1468: Add type parameter support for scala.DynamicNicolas Stucki2016-09-051-14/+0
|
* Adress reviewers commentsMartin Odersky2016-07-171-1/+1
|
* Proparage function result constrains when inferring parameter typesMartin Odersky2016-07-161-1/+12
| | | | | | | | If an application has functions with implicit parameter types we need to be more aggressive about propagating knowledge of the expected result type into the constraint. Fixes #1378.
* Use hasNamedArgs instead of repeating test inline.Martin Odersky2016-02-191-0/+4
|
* Shorten ..Class.typeRef to ..TypeMartin Odersky2015-11-091-1/+1
| | | | | Since we now have two forms of (almost) everything in Definitions, might as well profit from it.
* Purity checking should take constant expressions into account.Martin Odersky2015-09-141-3/+11
| | | | | | | A constant expression with pure arguments is pure. Previously, this was not taken into account, which meant that literalize did not work for constant expressions contiaining primitive operations or String adds.
* Make named repeated parameters discoverable during PatMat.Dmitry Petrashko2015-06-191-1/+2
| | | | | | They used to be discoverable using repeatedType, but ElimRepeated eliminates it. Instead I'm using internal synthetic Typed nodes name, similar to how it's done for non-star Wildcards. This makes handling Wildcards and Wildacard_Star more symmetric in patmat.
* Use FlagSet directly instead of defKindMartin Odersky2015-06-161-17/+9
| | | | | Instead of classifying class members with a TreeInfo.DefKind, we use directly the flags into which kinds were previously translated.
* Produce PureInterface flag together with NoInits flagMartin Odersky2015-06-161-8/+24
| | | | | | | | | | | | The previous stale symbol was discovered because NormalizeFlags looks at all declarations of a MoInits trait in the SymTransformer. I.e it does this for all no-init traits, whether loaded from a classfile or currently compiled. This is wasteful because it forces too many definitions. The new scheme drops the scan in favor of producing PureInterface together with NoInits. PureInterface is already read as a flag from Java snd Scala2 classfiles. For source and Tasty it is now generated as members are indexed.
* Fix #651 Generalize criterion for isOpAssignMartin Odersky2015-06-151-1/+1
| | | | | Methods like + can have multiple parameters. In that case += also takes multiple parameters.
* Correct a large number of typos.Jason Zaugg2015-05-141-1/+1
| | | | | I scanned the main sources with IntellIJ's spell checker and corrected what showed up.
* Pickling modularization reorgMartin Odersky2015-05-021-1/+1
| | | | | | | The pickling package got rather large and confusing with three separate tasks that each had their own conventions: read JVM classfiles, read Scala2 pickle info, read Tasty. The classes for each task are now in separate packages.
* Merge pull request #500 from dotty-staging/implement/i499Dmitry Petrashko2015-04-301-4/+5
|\ | | | | Implement/i499
| * Allow byname repated parametersMartin Odersky2015-04-241-4/+5
| | | | | | | | Implements #499
* | Produce one TASTY pickling per top-level class.Martin Odersky2015-04-241-0/+28
|/ | | | | | | If a unit has several top-level classes or object (which are not linked classes of each other) each gets its own pickle information, which contains any enclosing package clauses and imports and then just the top-level class/object and its companion object.
* Remove trailing spaces in Dotty source.Dmitry Petrashko2015-04-091-2/+2
|
* Fix refPurity: was using wrong function to detect if term is stable.Dmitry Petrashko2015-04-011-1/+1
|
* Compute PureInterface flag after pickling.Martin Odersky2015-03-181-8/+3
| | | | | | | | | | ElimLocals becomes a slightly less trivial transform: NormalizeFlags. It also computes PureInterface flag, thus relieving Namer and Unpickler from doing the same in two different ways. Besides, the computation in Namer/TreeInfo was flawed because it did not take into account that nested non-static classes are not allowed in an interface (only static classes are, but these would not be members of the interface in the Scala sense).
* Avoid capturing context in lazy treesMartin Odersky2015-03-181-7/+9
| | | | | | | | | | | | | | | | | | Lazy trees can live longer than runs, so it is important that they capture as little as possible. In particular they should not capture contexts. This change led with a ripple through effect to many changes where operations now have to parameterzied with contexts, in particular in what concerns tree folding. The changes in turn uncovered some areas where dotc was incompatible with scalac, and flagged correct things as errors. These will be fixed in the next commits. Another small twist: EmptyTrees will not be read in delayed mode, so that one can check for lacking definitions without deserializing the rhs.
* Make some tree fields lazyMartin Odersky2015-03-181-6/+5
| | | | | | | | | | | | | | | | Lazy fields are - the rhs field of a ValDef or DefDef - the body field of a Template These can be instantiated with Lazy instances. The scheme is such that lazy fields are completely transparent for users of the Trees API. The only downside is that the parameter used to initialize a potentially lazy field has a weak type (now it's Any, with Dotty it would be a union type of the form `T | Lazy[T]`. Therefore, the parameter cannot be recovered through pattern matching.
* Drop modifiers as separate data from MemberDef treesMartin Odersky2014-11-101-29/+13
| | | | Typed MemberDef trees now take the modifiers from their symbol's data.
* Clean up code relating to interfaces.Martin Odersky2014-11-101-6/+9
| | | | | | | | | | Previous implementation was confused about the meaning of interface (with default methods or without?). Now instead of Interface/JavaInterface we have PureInterface - all members are abstract methods NoInits - all members are methods
* Refactored TreeTypeMapMartin Odersky2014-08-181-0/+15
| | | | Goes into a separate source files. Several simplifying refactorings.
* Split Nullarify functionality to ElimByName, ErasureMartin Odersky2014-08-171-1/+1
| | | | | | | | | | | | | New phase ElimByName elimintaes by-name parameters. All other occurrences of parameterless methods and ExprTypes are eliminated in erasure. The reason for the split like this is that it is very hard for Nullarify to determine when to insert ()'s. The logic for this is fragile because we need to look at previous denotations which might not exist (before splitter) or might result from a merge between parameterless and nullary methods. In Erasure the same is much simpler to achieve.
* ParamAccessors are assumed to have definitionMartin Odersky2014-08-091-1/+1
| | | | Would be flagged as unimplemented members in refChecks otherwise
* Annotation decorators for symbolsMartin Odersky2014-08-031-2/+10
| | | | | | Added decorators for symbols that can query specific annotations and annotation arguments (for now, -deprecated and -migration are added)
* Eliminate JavaRepeatedParamClassMartin Odersky2014-08-031-1/+0
| | | | | | | Having two repeated param classes (and two types) does not work, because we need to maintain an overriding relationship between Scala repeated param methods and Java repeated param methods (this will be resolved later by bridges).
* Small cleanups and additions.Martin Odersky2014-07-171-1/+1
|
* Revised purity tests in TreeInfoMartin Odersky2014-07-171-26/+55
| | | | | | | | | Added two levels: pure and idempotent and fixed what look like obvious bugs. It seems the previous treatment confused the two levels. Changed EtaExpansion and Erasure to use Pure instead of Idempotent where appropriate.
* Refactor TreeInfo#defPathJason Zaugg2014-03-161-22/+11
| | | | Uses a TreeAccumulator, rather than ad-hoc descent through `productIterator`.
* Fixed parse error with @uncheckedMartin Odersky2014-03-131-1/+1
| | | | Dotty currently cannot parse @unchecked annotations in pattern types. That's why the previous commit failed. We need to come back to this and fix it. For the moment, to make on the current branch, the annotation is removed.
* Bullet-proofing companion objectsMartin Odersky2014-03-131-3/+63
| | | | | | | | | | | | Companion class/module computations now also work for local classes and modules. For this to work, either one of two conditions must be met: (1) some enclosing context refers to a scope that contains the companions. (2) the context's compilation unit has a typed tree that contains the companions. (1) is usually true when type-checking, (2) when transforming trees. Local companions are searched as follows: If (2) holds, we locate the statement sequence containing the companions by searching down from the root stored in the compilation unit. Otherwise, we search outwards in the enclosing contexts for a scope containing the companions.
* Fix isWildcardStarArg test so that it works also for typed trees.Martin Odersky2014-01-181-2/+3
|
* Fixing a type problem where code does not compile under dotty.Martin Odersky2014-01-021-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | ... and I believe should not compile under Scala2x either. The problem is in line 361 of TreeInfo.scala methPart(tree) match { ... Here, tree: tpd.Tree methPart: (tree: this.Tree): Tree So we need to show that tpd.Tree <: this.Tree LHS expands to ast.Tree[Type] RHS expands to ast.Tree[T] where T >: Untyped is TreeInfo's type parameter Since Tree is contravariant, we need to etablish T <: Type but I see nothing that could prove this. The Dotty typechecker detected the problem, yet Scala2x's didn't. Need to follow up on why not. For now, adding the necessary constraint to the codebase.
* Avoiding redundant tuple formations.Martin Odersky2013-12-271-0/+10
| | | | | | | | | | | | In a case like val (x, y) = if (...) (a, b) else (c, d) we can pass the tuples directly. Previously, this would have been translated to val (x, y) = (if (...) (a, b) else (c, d): @unchecked) match { case (s, t) => (s, t) }
* Typing by-name parameters with ExprTypes.Martin Odersky2013-12-221-7/+0
| | | | To avoid duplication between by-name parameters and expr types, we treat by-name parameters as as having ExprType. A part of this is introducing ByNameTypeTree, a specific tree class for => T types.
* Not counting type arguments for numArgsMartin Odersky2013-12-221-2/+1
|
* Refinement to shadowing checking for implicitsMartin Odersky2013-12-191-0/+6
| | | | Shadowing got confused if the shadowing expression truned out to be a closure.
* Three bugfixes to typing.Martin Odersky2013-12-171-1/+1
|
* Fixed several deep problems in handling of types and symbols.Martin Odersky2013-12-141-0/+9
| | | | | | | | | 1. We forgot to mark declaration symbols Deferred. 2. Types with NoPrefix and the same name got identified. Fixed by adding a new category WithNoPrefix to named types, and changing the way named types get generated. 3. Self types lacked parameters. (Question: Do we need to also track type members?) 4. Printers caused cyclic reference errors. Now some print operations are more careful with forcing. 5. Namedparts accumulator has to be more careful with ThisTypes. Because self types now contain parameters, which might lead back to this, we only add the class name (or the source module, if it's a module class). 6. toBounds in TypeApplications needs to use Co/Contra aliases for expanded name parameters, not just local ones.
* Skipping TypedSplices in TreeInfo methods.Martin Odersky2013-12-111-19/+28
| | | | Before, TreeInfo would mis-predict whenever trees were inserted with TypedSplice. We should make sure the rest of the compiler also takes TypedSplices into account when matching on trees. It's a systemic risk. Not sure we can avoid it with a better design.