aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/Implicits.scala
Commit message (Collapse)AuthorAgeFilesLines
* Fix of t0786: view boundsMartin Odersky2014-03-211-1/+1
| | | | | | | Previously, only implicit method types were eligible as views. This is too strict, as it rules out view bounds. We now also consider types that derive from Function1. The reason for not allowing any type is that this would cause us to check many more types for applicability when an implicit view is searched.
* Fix of t0591: implicitlyMartin Odersky2014-03-211-5/+0
| | | | A debug assertion in implicitSearch gave a false alarm and was removed.
* First step towards Typer Reorganization.Martin Odersky2014-03-071-1/+1
| | | | | | | | | | | | | | | | | Goal is better modularization and avoiding code duplication and divergence between Typer and tpd. As a first step, we split Inferencing into Inferencing, Checking, and ProtoTypes. Inferencing and Checking become Typer traits, while ProtoTypes remains a global object. Eventually: - we want to have a SimpleTyper, which does the main stuff in tpd, and can mixin either full checking or no checking. Each method in SimpleTyper takes an untyped tree (which is assumed to have typed arguments) and adds a toplevel type to that tree. The methods subsume the type-checking parts in Typers, except for (1) simplifications and expansions (2) computing prototypes and recursing with them into childtrees (3) adaptation. The method calls the necessary checking operations, which may however be stubbed out. The idea is already exercised in the typechecking code for Literal and New, except that for now it calls methods in tpd (they will become methods in SimpleTyper instead). - Typer should inherit from SimpleTyper, and forward all logic except for (1) - (3) to it. - tpd should call the simple typer it gets from ctx.typer - ctx.typer should be a SimpleTyper, not a complete one.
* Avoid memory leaks on repeated compilation.Martin Odersky2014-02-241-0/+2
| | | | | | | | | | | | | | | | | Several measures: 1. Invalidate classOfId and superIdOfClass in ContextBase after each run. These contain local classes that should become inaccessible. 2. Also clear implicitScope cache that maps types to their implicit scopes after each run. (not sure whether this is needed; it did show up in paths from root, but on second thought this might have been a gc-able cycle. 3. Avoid capturing contexts in lazy annotations. 4. Avoid capturing contexts in functions that compute souceModule and moduleClass 5. Avoid capturing contexts in Unpickler's postReadOp hook.
* Performance improvements: Changes to TypeAccumulators and variances.Martin Odersky2014-02-241-1/+1
|
* Disentangling SelectionProto and RefinedTypeMartin Odersky2014-02-211-1/+1
| | | | There were too many problems caused by it, and too little gained. So, now SelectionProto is no longer a Subtype of RefinedType.
* Two performance optimizationsMartin Odersky2014-02-131-3/+4
| | | | | 1) Split out wildApprox into separate function 2) Be more careful not to follow static prefix chains where not needed
* Merge branch 'wip/bring-forward': Incremental compilationMartin Odersky2014-02-101-1/+1
|\ | | | | | | | | 1) Make definitions load symbols in current run 2) Change handling of invalid parents. Instead of a copied denotation, we now invalidate the caches of the existing one. (Copying was not enough, as old versions of denotations kept leaking in).
| * New scheme for incremental invalidation of parents.Martin Odersky2014-02-101-2/+2
|/
* Fix bug for reading type arguments in ClassfileParserMartin Odersky2014-02-061-2/+3
|
* Dropping eligibility of conforms as an implicit conversion.Martin Odersky2014-02-031-8/+3
| | | | "conforms" is no longer special-cased to be eligible as a implicit conversion. Only implicit methods are eligible, whereas conforms is an implicit value with an apply method. So far, "conforms" as an implicit conversion masked in effect some type inference bugs. With the previous two commits, it is no longer necessary because two type inference bugs got fixed.
* Relaxing check that implicits must have explicit return typeMartin Odersky2014-02-021-1/+1
| | | | | | Now this is required only for members of a template. Local statements can still have implicits with no result type. (Maybe we need to get back on this). Also, changed Dotty itself and tests to adhere to the new restriction.
* Improve eligible caching in implicit search.Martin Odersky2014-02-021-1/+1
| | | | Improves effectiveness of elidable cache from ~66% to ~85% and reduces # of implicits that need to be checked after discarding to about 20% what it was before.
* Avoid accessing implicits that come from root imports that are hidden by ↵Martin Odersky2014-02-021-3/+15
| | | | | | | | | | | | some nested import. This also changes the criterion when a root import is disabled. A root import is now disabled if there is an inner import from the same package or module, and the inner import contains at least one disabling clause X => _. (The latter crierion is new; without it, we would consider something like import scala.{collections => c} as a hiding import for Scala, which seems to go too far.)
* wip for implicits handling root imports.Martin Odersky2014-02-021-6/+6
|
* Cheaper eligibility test for PolyTypes.Martin Odersky2014-02-021-10/+17
| | | | Instead of doing a wildApprox of the whole type, we fuse with the logix for method types and just do a wild approx of the single method type argument we have to test.
* Refactoring implicit discardsMartin Odersky2014-02-011-2/+41
| | | | | (1) Moved into refMatches, to avoid normalize on references that are discarded anyway (2) Added another check if the expected type is a value class
* Make argument types of viewproto undergo WildApprox before testing for ↵Martin Odersky2014-02-011-5/+13
| | | | | | eligibility. Unless we do this, typevars would sneak into eligibility checks.
* Replacing most occurrences of HashMap with AnyRefMapMartin Odersky2014-01-301-15/+16
|
* Better implicit loggingMartin Odersky2014-01-291-5/+19
|
* Better tracking of implicit searchMartin Odersky2014-01-291-4/+13
| | | | We now track eligible calls and the number of refs tested in an eligible call.
* New treatment of uniquesMartin Odersky2014-01-261-0/+1
| | | | | | | | To avoid to always create a type before checking its uniqueness we specialize on the three most common categories: RefinedTypes, TypeBounds and NamedTypes. Each category gets its own uniques map. Hashing is disentangled from Types. The new treatement seems to give some improvement (2-5%?) but not much.
* Special casing of numeric widenings in viewExistsMartin Odersky2014-01-261-2/+13
| | | | | | To save time we handle these directly, rather than looking for implicit conversions. Reason: this saves time (looks like 5-10% of frontend), and we know these are always available. The scheme would be foiled if someone introduced additional implicit conversions between numeric types. We could detect and forbid that.
* Update to 2.11Martin Odersky2014-01-261-1/+1
| | | | Previous flagsString is no longer accessible. Have to use Dotty's mechanism to show flags,
* For a typeRef, prefer info.isAlias over symbol.isAliasTypeMartin Odersky2014-01-201-1/+1
| | | | Reason: This works even for typeRefs with joint-ref denotations, even if the symbol does not exist. The only reason to use symbol.isAliasType is if info.isAlias can produce a cycle.
* Fix to computation of implicit scopesMartin Odersky2014-01-181-2/+7
| | | | For packages, the implicit scope consists of the implicit definitions in a nested `package` object, not the package itself.
* Refactoring to avoid multiple overloaded traceIndent methods.Martin Odersky2014-01-161-5/+7
|
* Generalize implicit scope of ThisTypeMartin Odersky2014-01-161-14/+23
| | | | The implicit scope of a ThisType is now always the implicit scope of the self type. This caused cycles which necessitated cycle detectors in namedParts and computeImplicitScope.
* Allow views when matching the result type of a selection prototype.Martin Odersky2014-01-151-5/+2
| | | | More generally, a refactoring of the Compatibility trait to use value passing instead of inheritance.
* Allow ExprType as the type of a view argument.Martin Odersky2014-01-141-1/+2
|
* Survive searching viers oper exprTypesMartin Odersky2014-01-131-1/+1
|
* Making some traces conditional on printers being enabled.Martin Odersky2014-01-131-4/+5
|
* Refine eligibilityMartin Odersky2014-01-091-1/+1
| | | | Because eligibility is tested in a context which is different from the implicit search context, we cannot assume that type variables have their constraint recorded. So we have to approximate subtype tests with PolyParams which are not in the constraint set.
* Don't do an implicit conversion to Any, AnyRef, or Unit.Martin Odersky2014-01-091-1/+4
|
* Change namedParts to also include the underlying types of TermRefs.Martin Odersky2014-01-081-1/+1
|
* Fix divergence test for implicitsMartin Odersky2014-01-061-1/+3
| | | | The test did not fire if the set of class symbols of the searched-for type was empty.
* Exclude inaccessible definitions from contextual implicit search.Martin Odersky2014-01-061-2/+4
|
* Make implicit scope work in the presence to TypeVarsMartin Odersky2014-01-061-55/+73
| | | | Need to pass a current context to be able to find instances of typevars.
* Propagate constraints on result type eagerly into implicit search.Martin Odersky2014-01-041-1/+1
| | | | Thus constraining the search space.
* Output cleanupsMartin Odersky2014-01-041-1/+3
|
* Fix in constrainResultMartin Odersky2014-01-041-0/+2
| | | | | | | | | | Need to handle the case of a curried method with result type (Ts)T and expected type Ts => T
* Avoiding converting with a view to a TypeVarMartin Odersky2014-01-021-1/+1
| | | | This triggered an assertion violation in ImplicitSearch. When checking an argument for a method, it's possible that the method parameter is a lower bound, and the argument is incompatible with that lower bound. In this case an implicit conversion towards the variable was searched, which leads to an explosion of the search space (the variable expands to WildcardType, so _every_ implicit is eligible). Better to search for a conversion to the lower bound (or, in fact, and equivalently, the underlying type parameter) instead.
* Tightening of position handlngMartin Odersky2013-12-291-1/+2
| | | | | | | 1) endPos works now even for NoPosition. 2) On the other hand, there's an assertion in Typer.typed which requires every non-empty tree that's type checked in a globally committable context to have a defined position. Some fixes were needed to make the tests pass the new assert.
* Typing by-name parameters with ExprTypes.Martin Odersky2013-12-221-1/+1
| | | | 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.
* More shadowing tweaking.Martin Odersky2013-12-191-4/+10
|
* Refinement to shadowing checking for implicitsMartin Odersky2013-12-191-2/+5
| | | | Shadowing got confused if the shadowing expression truned out to be a closure.
* 3 changes to implicit searchMartin Odersky2013-12-191-4/+13
| | | | | | | | 1. Shadowing tree uses adaptation funProto of prototype. Previously many shadowing tries failed with errors like "need to follow with "_" to adapt to function". These early failures hid potential shadowing conflicts. 2. Shadowing conflict testing is now done using symbols instead of comparing references. Comparing references gave false negative when a shadoing tree had inferred type parameters, for instance. There were other problems as well. Generally, comparsing references seems too fragile. 3. Inferred views are now re-adapted. This is necessary if the view itself takes another implicit parameter.
* Following type aliases when pattern matching.Martin Odersky2013-12-191-1/+1
| | | | | | | | | | | | | | | Faced with a pattern like Apply(x, xs) we first look for an Apply object which is an extractor. If this fails, we now interprete Apply as a type. If it is a type alias which points to a class type that has a companion module, we then try that companion module as an extractor. Scala 2.x does ot that way, and it's used widely within dotty itself. Think tpd.Apply as the found object, Trees.Apply as the extractor. Also, added a fix to normalization which made normalization go deep into a method type.
* Fixes for by-name argumentsMartin Odersky2013-12-171-1/+2
| | | | Previously, we did not strip off the => when comparing against expected type.
* Added divergence check for implicit searchesMartin Odersky2013-11-301-1/+69
|