aboutsummaryrefslogtreecommitdiff
path: root/compiler/src/dotty/tools/dotc/typer/Namer.scala
Commit message (Collapse)AuthorAgeFilesLines
* Add fullyDefinedType for class parent typesMartin Odersky2017-04-111-1/+1
| | | | | | If we do not do that, any type variables in the parent type get interpolated later, when the whole primary constructor is typed. But by then we miss the context of what their variance was.
* Cleanups of NameOpsMartin Odersky2017-04-111-8/+4
| | | | Remove unused functionality
* Bug fixesMartin Odersky2017-04-111-1/+1
| | | | nameddefaults.scala now compiles without crashing
* Fix #2198: Don't widen module singletonsMartin Odersky2017-04-091-2/+4
| | | | | | | | Since module classes are a compiler-generated construct that's not directly visible to programmers, it seems better not to automatically widen a module singleton to its underlying class. Fixes #2198.
* Eliminate LambdaAbstractMartin Odersky2017-04-061-4/+2
| | | | Use fromParams instead.
* Further refactoringsMartin Odersky2017-04-061-2/+2
| | | | | - Use TypeLambda instead of PolyType. - Further harmonize factory operations
* Rename PolyTypeTree -> LambdaTypeTreeMartin Odersky2017-04-061-3/+3
|
* Harmonize paramTypes and paramBoundsMartin Odersky2017-04-061-1/+1
| | | | | | MethodTypes have paramTypes whereas PolyTypes have paramBounds. We now harmonize by alling both paramInfos, and parameterizing types that will become common to both.
* Allow value expansion of modules in mergeCompanionDefsMartin Odersky2017-04-041-1/+0
|
* Create dummy companions for classes without a real oneGuillaume Martres2017-03-291-5/+16
| | | | | | | | | | | | | | | | In #2139 I added code to create dummy companions for companion-less objects, but not for companion-less classes because I thought it wasn't needed. But it turns out that even if the classpath only has `Foo.class` and not `Foo$.class`, a module for `Foo` is entered by `initializeFromClassPath` when it calls `enterClassAndModule`, so we have to add dummy companions to classes. I don't have a test to illustrate this issue, but note that it fixes the incremental compilation bug demonstrated by https://github.com/dotty-staging/dotty/commits/incremental-compilation-bug. Note: I verified that adding a dummy companion to "class Foo" did not cause the backend to emit a Foo$.class, so this should have no visible impact.
* Namer#createCompanionLinks: avoid using denotNamedGuillaume Martres2017-03-241-4/+4
| | | | | | | | | | | The previous commit introduced two new usages of `denotNamed` which broke tests/run/t1987b because `denotNamed` indirectly calls `packageObj` which caches the package object, except that at this point the package object is not yet entered, so the cache was incorrect. We fix this by using `effectiveScope.lookup` instead since we only need to look into the current scope, this is also true for the two existing usage of `denotNamed` in `createCompanionLinks` so they were also replaced by `effectiveScope.lookup`.
* Fix #2137: Create dummy companions for top-level objects without a real oneGuillaume Martres2017-03-231-0/+19
| | | | | | | | | | | | | | | | | Previously, we sometimes ended up forcing a companion class symbol from a previous run or from the classpath which lead to weird issues like in `false-companion`. Even if we end up not forcing such a symbol, its presence can still lead to issue: before this commit incremental compilation of `dotty-compiler-bootstrapped` was broken because we recorded a false dependency on the non-bootstrapped `dotty-compiler` jar. The added test is currently marked pending because it does not work with JUnit (which doesn't handle separate compilation), only partest. I didn't managed to get it to work right, and this won't be necessary once our testing framework is overhauled by https://github.com/lampepfl/dotty/pull/2125 anyway, so I'll just have to remember to enable this test afterwards.
* Remove warning from non exhaustive match in mergeCompanionDefs.Nicolas Stucki2017-03-161-1/+1
|
* Merge pull request #2057 from dotty-staging/merge-companionodersky2017-03-091-31/+97
|\ | | | | support merging companion objects in expanded trees
| * address review feedbackliu fengyun2017-03-071-29/+34
| |
| * support merging companion objects in expanded treesliu fengyun2017-03-071-31/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previous implementation is problematic when there are multiple transforms before typer: 1. There might be objects needing merging that only exist in the expanded trees, which cannot be handled by the previous algorithm. 2. There may be companion object and class defined only in the expanded trees, the previous algorithm doesn't create links for them. This PR simplifies the companion object merging logic and fixes the problems above. In fact, this PR supports multiple pre-typer transform during expansion. The protocol is that the expansion of a MemberDef is either a flattened thicket or a non-thicket tree.
* | Fix #2067: Compute defKind at Typer, not NamerMartin Odersky2017-03-081-2/+0
|/ | | | | | | It's hard to predict for defKind all the desugarings that can be applied to a definition. Better to do it once the desugarings have been applied. NoInit and PureInterface are both tested only after Typer, so it's OK to delay their initialization until regular Typer.
* Drop named type parameters in classesMartin Odersky2017-03-041-49/+5
| | | | | | | | | | | | | Drop the [type T] syntax, and what's associated to make it work. Motivation: It's an alternative way of doing things for which there seems to be little need. The implementation was provisional and bitrotted during the various iterations to introduce higher-kinded types. So in the end the complxity-cost for language and compiler was not worth the added benefit that [type T] parameters provide. Noe that we still accept _named arguments_ [A = T] in expressions; these are useful for specifying some parameters and letting others be inferred.
* adjustModuleCompleter: Avoid capturing ContextGuillaume Martres2017-02-201-11/+15
| | | | | | | | | | | | | | | | Previously we computed the scope in `findModuleBuddy` using `this.effectiveScope`, this means that we captured `this` which has a self-type of `Context`, replacing it by `ctx.effectiveScope` would be wrong since we are interested in the scope at the time `adjustModuleCompleter` was called, not the scope at the time the completer is called. Therefore, we have to eagerly compute `this.effectiveScope` so that we don't capture the Context but can use the right scope in `findModuleBuddy`. We also move `findModuleBuddy` to a companion object to avoid accidental captures of `this`. This capture lead to crashes in the IDE.
* ImportInfo: Do not capture ContextGuillaume Martres2017-02-181-1/+1
|
* Merge pull request #1953 from dotty-staging/fix-wildapproxodersky2017-02-081-1/+1
|\ | | | | Fix to wildapprox
| * Fix wildApprox functionMartin Odersky2017-02-071-1/+1
| | | | | | | | | | | | | | | | | | | | f-bounded-case-class.scala exhibited a StackOverflow in wildApprox before the fixes. The problem was due to F-bounds. Note: wildApprox is performance critical. I ran timed-bootstrap-repeated a couple of times to verify that the changes did not affect runtimes in significant ways. We should also watch out for a slowdown in the benchmark tests.
* | Weaken assumption in mergeCompanionDefsliu fengyun2017-02-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | Previously `mergeCompanionDefs` assumes that if the attachment of class `Foo` is as follows: x :: y :: tdef @ TypeDef(_, templ) Then the `tdef` must be `Foo$`. When there are multiple pre-typer transforms, this is not necessarily true. For example, an annotation macro expansion may expand a non-case class `Foo` to `class Foo; object FooA`. We need to check the name of `tdef` to be equal to `Foo$`.
* | Merge pull request #1929 from dotty-staging/multi-levelodersky2017-02-021-2/+4
|\ \ | |/ |/| support pre-typer transform of trees
| * support pre-typer transform of treesliu fengyun2017-02-021-2/+4
| | | | | | | | | | | | | | | | | | | | | | Currently `mergeCompanionDefs` assume `ModuleDef` is expanded exactly to `module val; module class`. To enable more general pre-typer transform, we need to weaken the assumption to that the first two elements of the thicket must be `module val; module class`. This change will enable transform def macros defined inside an object, as well as other pre-typer transforms.
* | Refactoring to make Checking not mutate denotationsMartin Odersky2017-02-021-3/+6
|/ | | | | avoidPrivateLeaks got moved from Checking to TypeAssigner, where it fits well besides the other avoid methods.
* Adopt scala's scheme for root import hidingMartin Odersky2017-01-151-3/+8
| | | | | | | | | | scalac hides a root import from Predef if there is an eplicit Predef import. We now do the same (previously we did this only if the overriding import undefined something, using a `x => _` syntax). To avoid cycles and races one had to be very careful not to force import symbols too early, so we now compare the name before the symbol proper. All this is likely temporary - the comment of ImportInfo#unimported points to a different, more systematic solution.
* Infer type parameters of anonymous class parents from expected typeMartin Odersky2016-12-171-5/+5
| | | | | | | If a parent type of an anonymous class is an Ident or Select which refers to a parameterized type, use the expected type to infer its type parameters. Fixes #1803.
* Better diagnosis for cyclic references caused by implicit searchMartin Odersky2016-12-121-1/+0
| | | | | | | | | Since we now allow to drop the explicit type of a local implicit val it can happen that this causes a cyclic reference, namely when the typechecking of the right-hand side involves an implicit search. It's unpractical and fragile to avoid this. Instead we give now a nice error message explaining the problem and how to fix it in source code.
* Drop explicit types for local implicit valsMartin Odersky2016-12-121-1/+1
| | | | | Drop explicit types for local implicit vals of type Context and Position. Exercises the functionality and shortens the code.
* Fix #1784: allow to omit types for local implicit valsMartin Odersky2016-12-121-3/+9
|
* Address reviewers commentsMartin Odersky2016-12-011-2/+2
|
* New phase for entering annotationsMartin Odersky2016-12-011-20/+89
| | | | | | If we want to do annotation macros right, we need to add annotations before completing definitions. This commit achieves that by adding a new "phase" between index and typecheck.
* Move compiler and compiler tests to compiler dirFelix Mulder2016-11-221-0/+1061