Commit Graph

143 Commits

Author SHA1 Message Date
Grzegorz Kossakowski a37d8d4770 Fix unstable existential type names bug.
Fix the problem with unstable names synthesized for existential
types (declared with underscore syntax) by renaming type variables
to a scheme that is guaranteed to be stable no matter where given
the existential type appears.

The sheme we use are De Bruijn-like indices that capture both position
of type variable declarion within single existential type and nesting
level of nested existential type. This way we properly support nested
existential types by avoiding name clashes.

In general, we can perform renamings like that because type variables
declared in existential types are scoped to those types so the renaming
operation is local.

There's a specs2 unit test covering instability of existential types.
The test is included in compiler-interface project and the build
definition has been modified to enable building and executing tests
in compiler-interface project. Some dependencies has been modified:

  * compiler-interface project depends on api project for testing
    (test makes us of SameAPI)
  * dependency on junit has been introduced because it's needed
    for `@RunWith` annotation which declares that specs2 unit
    test should be ran with JUnitRunner

SameAPI has been modified to expose a method that allows us to
compare two definitions.

This commit also adds `ScalaCompilerForUnitTesting` class that allows
to compile a piece of Scala code and inspect information recorded
callbacks defined in  `AnalysisCallback` interface. That class uses
existing ConsoleLogger for logging. I considered doing the same for
ConsoleReporter. There's LoggingReporter defined which would fit our
usecase but it's defined in compile subproject that compiler-interface
doesn't depend on so we roll our own.

ScalaCompilerForUnit testing uses TestCallback from compiler-interface
subproject for recording information passed to callbacks. In order
to be able to access TestCallback from compiler-interface
subproject I had to tweak dependencies between interface and
compiler-interface so test classes from the former are visible in the
latter. I also modified the TestCallback itself to accumulate apis in
a HashMap instead of a buffer of tuples for easier lookup.

An integration test has been added which tests scenario
mentioned in #823.

This commit fixes #823.
2013-10-29 16:39:50 +01:00
Grzegorz Kossakowski 59de0f00b0 Remove long comment that explains phase ordering issues.
As pointed out by @harrah in #705, we might want to merge both API
and dependency phases so we should mention that in the comment explaining
phase ordering constraints instead.

I'd still like to keep the old comment in the history (as separate commit)
because it took me a while to figure out cryptic issues related to
continuations plugin so it's valuable to keep the explanation around in
case somebody else in the future tries to mess around with dependencies
defined by sbt.
2013-10-24 16:44:46 +02:00
Grzegorz Kossakowski e8746dc0c7 Add a bit documentation to Dependency phase.
It gives some high-level overview of what this phase does.
2013-10-24 16:44:45 +02:00
Grzegorz Kossakowski 838416360a Move dependency extraction into separate compiler phase.
This is the first step towards using new mechanism for dependency
extraction that is based on tree walking.

We need dependency extraction in separate phase because the code
walking trees should run before refchecks whereas analyzer phase runs
at the very end of phase pipeline.

This change also includes a work-around for phase ordering issue with
continuations plugin. See included comment and SI-7217 for details.
2013-10-24 16:44:45 +02:00
Grzegorz Kossakowski fea18a4fbe Remove AnalysisCallback.{beginSource, endSource} methods.
As pointed out by @harrah in #705, both beginSource and endSource are
not used in sbt internally for anything meaningful.

We've discussed an option of deprecating those methods but since they
are not doing anything meaningful Mark prefers to have compile-time
error in case somebody implements or calls those methods. I agree with
that hence removal.
2013-10-24 16:44:45 +02:00
Jason Zaugg c4efcc4df7 Make the DelegatingReporter aware of -nowarn
The test case compiles a project without and with this
setting and checks that a warning is and isn't emitted
respectively.

It's a multi-project build; this bug didn't seem to turn
up in a single-project build.
2013-09-05 13:31:04 -04:00
Grzegorz Kossakowski beea6a9b4a Move API extraction logic to a separate class.
This way we have a little bit more clear separation
between compiler phase logic and the core logic responsible for
processing each compilation unit and extracting an api for it.

As added benefit, we have a little bit less of mutable state
(e.g. sourceFile doesn't need to be a var anymore).

The API extraction logic contains some internal caches that are
required for correctness. It wasn't very clear if they have to
be maintained during entire phase run or just during single compilation
unit processing. It looks like they have to be maintained during
single compilation unit processing and refactored code both
documents that contracts and implements it in the API phase.
2013-07-24 15:18:44 -07:00
Grzegorz Kossakowski 7d4cf7b8ab Factor out class file lookup out of Analyzer class.
Move logic related to class file lookup to separate class that
can be reused outside of Analyzer class.
2013-07-23 17:11:42 -07:00
Grzegorz Kossakowski aec466cb4d Factor out compiler interface compatibility layer.
Move collection (a class `Compat`) of compatibility hacks into separate
file. This aids understanding of the code as both Analyzer and API make
use of that class and keeping it `Analyzer.scala` file suggested that
it's used only by Analyzer.
2013-07-23 15:19:24 -07:00
Mark Harrah ab5e81fc23 Merge remote-tracking branch 'cancel-bug' into 0.13 2013-07-19 18:56:01 -04:00
Grzegorz Kossakowski d77930394f Handle compilation cancellation properly.
Incremental compiler didn't have any explicit logic to handle
cancelled compilation so it would go into inconsistent state.

Specifically, what would happen is that it would treat cancelled
compilation as a compilation that finished normally and try to
produce a new Analysis object out of partial information collected
in AnalysisCallback. The most obvious outcome would be that the
new Analysis would contain latest hashes for source files. The
next time incremental compiler was asked to recompile the same files
that it didn't recompile due to cancelled compilation it would think
they were already successfully compiled and would do nothing.

We fix that problem by following the same logic that handles compilation
errors, cleans up partial results (produced class files) and makes sure
that no Analysis is created out of broken state.

We do that by introducing a new exception `CompileCancelled`
and throwing it at the same spot as an exception signalizing compilation
errors is being thrown. We also modify `IncrementalCompile` to
catch that exception and gracefully return as there was no compilation
invoked.

NOTE: In case there were compilation errors reported _before_
compilation cancellations was requested we'll still report them
using an old mechanism so partial errors are not lost in case
of cancelled compilation.
2013-07-19 14:39:26 -07:00
Mark Harrah 4b8f0f3f94 Use IMain.bindValue to bind repl values. This does a better job of getting the type to use for a bound value. 2013-07-17 14:58:53 -04:00
Mark Harrah 0a7a579f5b Merge ExtendedReporter into Reporter. 2013-05-27 19:12:39 -04:00
Mark Harrah 626038bece Merge branch 'feature/inc-track-inherit' into 0.13 2013-05-01 19:25:01 -04:00
Mark Harrah 0b876cc57d fix compiler interface compatibility with 2.11 2013-04-27 16:27:57 -04:00
Mark Harrah 4dc75343ae Record and persist public inheritance dependencies.
Includes placeholders for adding public inherited dependencies for Java classes.
2013-04-26 22:35:27 -04:00
Mark Harrah c355bef200 Track public inherited dependencies.
There is a public inherited dependency on each (normalized) base
class of a public template (class, module, trait, structural type).
2013-04-26 22:35:27 -04:00
Mark Harrah 0e1f211fe5 move to compiler's built-in moduleSuffix method 2013-04-26 18:52:16 -04:00
Grzegorz Kossakowski 3ba9348740 Do not normalize types in the api extraction phase.
In summary this commit:

  * drops type normalization in api phase but keeps dealiasing
  * fixes #736 and marks corresponding test as passing

I discussed type normalization with @adriaanm and according to him
sbt shouldn't call that method. The purpose of this method to
convert to a form that subtyping algorithm expects. Sbt doesn't need
to call it and it's fairly expensive in some cases.

Dropping type normalization also fixes #726 by not running into
stale cache in Scala compiler problem described in SI-7361.
2013-04-27 00:31:31 +02:00
Grzegorz Kossakowski fbe4dedd11 Remove trailing whitespace in API.scala 2013-04-27 00:31:31 +02:00
Mark Harrah bef8ce05b9 Properly track 'abstract override' modifier. Ref #726. 2013-04-15 14:12:15 -04:00
Mark Harrah 6def08e029 remove resident compiler code
The infrastructure for resident compilation still exists,
but the actual scalac-side code that was backported is removed.
Future work on using a resident scalac will use that invalidation
code directly from scalac anyway.
2013-04-09 20:13:06 -04:00
Mark Harrah 008c2928b6 note that mixing RangePositions into Global isn't necessary in 2.11 2013-03-13 12:40:03 -04:00
Mark Harrah f2d29d8678 Export approximate command lines executed for 'doc', 'compile', and 'console' 2013-02-28 17:59:38 -05:00
Jason Zaugg c597b48eda Stop using Predef.error
We'd like to remove this from 2.11.0.

This patch should be backported to 0.12.3.
2013-01-28 22:29:48 +01:00
Mark Harrah 070a87dda4 Call non-deprecated isRawType instead of isRaw 2013-01-16 10:26:32 -05:00
Grzegorz Kossakowski 4c1c31e190 Fix for dependency on class file corresponding to a package. (#620)
While trying to determine binary dependencies sbt lookups class files
corresponding to symbols. It tried to do that for packages and most of the
time would fail because packages don't have corresponding class file
generated. However, in case of case insensitive file system, combined
with special nesting structure you could get spurious dependency.
See added test case for an example of such structure.

The remedy is to never even try to locate class files corresponding to
packages.

Fixes #620.
2012-12-10 13:53:52 -05:00
Grzegorz Kossakowski ef39aeb9c1 Follow source layout convention supported by Eclipse.
Moved source files so directory structure follow package
structure. That makes it possible to use Scala Eclipse plugin
with sbt's source code.
2012-12-07 10:27:08 -08:00
Adriaan Moors f7be122eb4 Run apiExtractor after pickler (configurable)
Extract the api after picklers, since that way we see the same symbol
information/structure irrespective of whether we were typechecking
from source / unpickling previously compiled classes.

Previously, the apiExtractor phase ran after typer.

Since this fix is hard to verify with a test (it's based on the
conceptual argument above, and anecdotal evidence of incremental
compilation of a big codebase), we're providing a way to restore the
old behaviour: run sbt with -Dsbt.api.phase=typer.

This fixes #609.
2012-12-06 19:35:51 -05:00
Adriaan Moors cb0e723923 Fix #610: represent refinement typerefs stably
goal:

a representation of a type reference to a refinement class that's stable
across compilation runs (and thus insensitive to typing from source or
unpickling from bytecode)

problem:

the current representation, which corresponds to the owner chain of the
refinement:

  1. is affected by pickling, so typing from source or using unpickled
  symbols give different results (because the unpickler "localizes"
  owners -- this could be fixed in the compiler in the long term)

  2. can't distinguish multiple refinements in the same owner (this is
  a limitation of SBT's internal representation and cannot be fixed in
  the compiler)

solution:

expand the reference to the corresponding refinement type: doing that
recursively may not terminate, but we can deal with that by
approximating recursive references (all we care about is being sound for
recompilation: recompile iff a dependency changes, and this will happen
as long as we have one unrolling of the reference to the refinement)
2012-12-06 19:11:12 -05:00
Lex Spoon b7250bb528 Fix -Yrangepos. Unlike other settings, it requires that a mixin be added to Global. 2012-12-03 20:34:11 -05:00
Mark Harrah d6072275aa replace Symbol.nameString calls with simpleName(Symbol). Fixes #577.
nameString is only for printing and has different behavior when scalac is
given -uniqid.
2012-10-15 12:42:27 -04:00
Mark Harrah 18a03f0e25 API extraction: handle any type that is annotated, not just the spec'd simple type. Fixes #559. 2012-10-05 09:06:35 -04:00
Mark Harrah 42042a9d85 2.8.1 compatibility for compiler interface 2012-08-27 08:33:33 -04:00
Eugene Vigdorchik 1b814ae8b1 Extend reporter to be used by the IDE. 2012-07-24 15:35:06 -04:00
Eugene Vigdorchik b5a29987e6 Changes required to use sbt as-is from Scala-IDE. 2012-07-13 14:33:26 -04:00
Mark Harrah 0de4444665 sync resident compiler code 2012-06-18 08:18:39 -04:00
Mark Harrah f53d20a7a3 disable resident-compiler related code paths when it isn't being used. fixes #486.
The underlying issue with the resident compiler needs fixing, however.
2012-06-16 23:40:52 -04:00
Mark Harrah 919ac33c1a compiler interface compatibility hardening 2012-06-10 23:06:35 -04:00
Mark Harrah b7df87e2d8 compiler interface source compatibility with Scala 2.8.1/0 2012-06-02 19:03:57 -04:00
Mark Harrah 4bc993e0ba Revert "remove unneeded unlinking in compiler interface"
Unlinking is actually needed.

This reverts commit 1581d1b7e1.
2012-06-02 19:03:57 -04:00
Mark Harrah 1581d1b7e1 remove unneeded unlinking in compiler interface 2012-05-30 07:41:02 -04:00
Mark Harrah 2db0101eb8 resident compiler that passes all tests
core logic from odersky/scala/topic/inkling
2012-05-30 07:13:15 -04:00
Mark Harrah 63895a3d77 source compatibility with 2.8.1, where resident mode can't be supported 2012-05-19 18:20:20 -04:00
Mark Harrah 50ddd485af add a missing 'lazy' 2012-05-13 22:38:00 -04:00
Mark Harrah 208b46fd10 resident mode: package objects 2012-05-13 21:31:40 -04:00
Mark Harrah 864580aae1 approximate type parameters and references by name
not as accurate, but simpler.
2012-05-12 23:12:29 -04:00
Mark Harrah 00d0918714 workaround separate compilation and raw types 2012-05-12 23:12:29 -04:00
Mark Harrah 99a04466f1 move to revised warning interface in the compiler 2012-05-06 14:15:03 -04:00
Mark Harrah e537cbc474 second part of fix for excessive recompilations 2012-04-30 20:34:48 -04:00