Commit Graph

77 Commits

Author SHA1 Message Date
Jean-Rémi Desjardins ca736e55d3 Minor code cleanup 2014-12-03 09:56:34 -08:00
Grzegorz Kossakowski 20f50100be Use Option.apply instead of Some.apply in ClassToAPI
When dealing with Java APIs (Java reflection in case of ClassToAPI), one
should always go through Option.apply that performs null check.

This is supposed to fix NPE reported in #1617. We don't have a reproduction
so this is just an educated guess.
2014-09-24 23:05:52 +02:00
Josh Suereth abffc3e1bd Bump expected 2.11 module versions so we can compile with 2.11
Add scala 2.11 test/build verification.

* Add 2.11 build configuratoin to travis ci
* Create command which runs `safe` unit tests
* Create command to test the scala 2.11 build
* Update scalacheck to 1.11.4
* Update specs2 to 2.3.11
* Fix various 2.11/deprecation removals
  and other changes.

Fix eval test failure in scala 2.11 with XML not existing.
2014-05-14 19:08:05 -04:00
Josh Suereth 244abd3b6f Scalariforming test code 2014-05-07 11:52:23 -04:00
Eugene Yokota adb41611cf added scalariform 2014-05-01 12:50:07 -04:00
Grzegorz Kossakowski 36db1207cf Move NameHashing from incremental to api subproject.
It should have been there from the beginning because NameHashing is tied
to internals of the API subproject.

It was added to incremental subproject by mistake.
2014-04-10 20:21:42 +02:00
Martin Duhem 5a40641cc1 Classes that only inherit a macro don't have a macro
Prior to this commit, a class that inherited a macro from another
class was considered by incremental compiler as having a macro.
Now, only classes that explicitly define a macro are considered as having
a macro. This influences decision whether to invalidate (recompile)
dependencies of a file that inherits a macro upon a whitespace change.
From now on, we don't invalidate dependencies in such case which
results in much better incremental compiler experience when macros are
being involved. Check #1142 for detailed discussion.

The change to the behavior is reflected by marking the
source-dependencies/inherited-macros test as passing.
The source-dependencies/macro test covers the case of defining the macro
directly in source file. Therefore we know that the desired behavior of
invalidating dependencies of macros is preserved.

Fixes #1142
2014-04-03 18:27:17 +02:00
Mark Harrah b09cf5b5e7 Fixes #1035 by catching the format error and returning the erased type as a backup.
Review by @gkossakowski.
2013-12-13 14:04:31 -05:00
Grzegorz Kossakowski 1bbbbb38c9 Get rid of MurmurHash.finalizeHash import in HashAPI.
That import is shadowed by the local definition of `finalizeHash`
introduced to HashAPI class.
2013-12-04 12:50:29 +01:00
Grzegorz Kossakowski fa220f372a Add overloaded constructor to HashAPI for backwards compatibility.
Add a variant of constructor to `HashAPI` that is binary and source
backwards compatible with sbt 0.13.0.
2013-12-04 12:49:15 +01:00
Grzegorz Kossakowski a9a709ccc0 Add hashing of public names defined in a source file.
A hash for given name in a source file is computed by combining
hashes of all definitions with given name. When hashing a single
definition we take into account all information about it except nested
definitions. For example, if we have following definition

class Foo[T] {
  def bar(x: Int): Int = ???
}

hash sum for `Foo` will include the fact that we have a class with
a single type parameter but it won't include hash sum of `bar` method.

Computed hash sums are location-sensitive. Each definition is hashed along
with its location so we properly detect cases when definition's signature
stays the same but it's moved around in the same compilation unit.

The location is defined as sequence of selections. Each selection consists
of a name and name type. The name type is either term name or type name.
Scala specification (9.2) guarantees that each publicly visible definition
is uniquely identified by a sequence of such selectors.

For example, if we have:

object Foo {
  class Bar { def abc: Int }
}

then location of `abc` is Seq((TermName, Foo), (TypeName, Bar))

It's worth mentioning that we track name-hash pairs separately for
regular (non implicit) and implicit members. That's required for name
hashing algorithm because it does not apply its heuristic when implicit
members are being modified.

Another important characteristic is that we include all inherited members
when computing name hashes.

Here comes the detailed list of changes made in this commit:

  * HashAPI has new parameter `includeDefinitions` that allows
    shallow hashing of Structures (where we do not compute hashes
    recursively)
  * HashAPI exposes `finalizeHash` method that allow one to capture
    current hash at any time. This is useful if you want to hash a list of
    definitions and not just whole `SourceAPI`.
  * NameHashing implements actual extraction of public definitions,
    grouping them by simple name and computing hash sums for each group
    using HashAPI
  * `Source` class (defined in interface/other file) has been extended to
    include `_internalOnly_nameHashes` field. This field stores
    NameHashes data structure for given source file. The NameHashes
    stores two separate collections of name-hash pairs for regular and
    implicit members.
    The prefix `_internalOnly_` is used to indicate that this is not an
    official incremental compiler's or sbt's API and it's for use by
    incremental compiler internals only. We had to use such a prefix
    because the `datatype` code generator doesn't support emitting access
    modifiers
  * `AnalysisCallback` implementation has been modified to gather all
    name hashes and store them in the Source object
  * TestCaseGenerators has been modified to implement generation of
    NameHashes
  * The NameHashingSpecification contains a few unit tests that make sure
    that the basic functionality works properly
2013-12-04 01:34:18 +01:00
Grzegorz Kossakowski 4b43110a2c Represent api changes as values and cleanup APIChanges class.
The main motivation behind this commit is to reify information about
api changes that incremental compiler considers. We introduce a new
sealed class `APIChange` that has (at the moment) two subtypes:

  * APIChangeDueToMacroDefinition - as the name explains, this represents
    the case where incremental compiler considers an api to be changed
    just because given source file contains a macro definition
  * SourceAPIChange - this represents the case of regular api change;
    at the moment it's just a simple wrapper around value representing
    source file but in the future it will get expanded to contain more
    detailed information about API changes (e.g. collection of changed
    name hashes)

The APIChanges becomes just a collection of APIChange instances.
In particular, I removed `names` field that seems to be a dead code in
incremental compiler. The `NameChanges` class and methods that refer to
it in `SameAPI` has been deprecated.

The Incremental.scala has been adapted to changed signature of APIChanges
class. The `sameSource` method returns representation of APIChange
(if there's one) instead of just simple boolean. One notable change is
that information about APIChanges is pushed deeper into invalidation logic.
This will allow us to treat the APIChangeDueToMacroDefinition case properly
once name hashing scheme arrives.

This commit shouldn't change any behavior and is purely a refactoring.
2013-11-11 15:43:28 +01:00
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
Mark Harrah b8b6426cf9 Allow main class to be non-public. Fixes #883. 2013-09-26 09:42:30 -04:00
Mark Harrah 4bf4a80b5e Deleted unused type parsing class 2013-07-09 14:55:30 -04:00
xuwei-k 3f2133729b allow java varargs main
http://docs.oracle.com/javase/specs/jls/se7/html/jls-12.html#jls-12.1.4
2013-06-16 15:47:47 -04:00
Mark Harrah d2d406969b Make imports from MurmurHash explicit for clarity. 2013-05-27 19:12:39 -04:00
Mark Harrah 7088a7dd5a test cases for Java inherited dependency extraction 2013-05-02 12:01:01 -04:00
Mark Harrah a867d8e87c extract public inherited dependencies from Java class files 2013-05-01 17:54:10 -04:00
Mark Harrah f6d73128fc deprecations 2013-02-25 09:24:04 -05:00
Mark Harrah 6e30bd7842 short-circuit the macro check in the incremental compiler if the source isn't a Scala source file 2013-02-22 16:31:32 -05:00
Grzegorz Kossakowski 4c261d360f Revert "Revert "Fix sbt/sbt#676: swapped declarations and members in `ClassToAPI`.""
This reverts commit 9dd5f076ea which was a revert
itself so we are back to the state before those two reverts.

The problem that caused revert that happened in 9dd5f076ea
has been fixed in 88061dd262.
2013-02-22 07:36:55 -05:00
Grzegorz Kossakowski 129df3e812 Fix problem with initialization order in `ClassToAPI.scala`.
In `ClassToAPI` both `Private` and `Protected` vals had forward
reference to `Unqualified` so they would get `null` as a result.
Fixed that by rearranging the order of vals being declared.

This fixes a problem described in 9dd5f076ea.
2013-02-22 07:36:55 -05:00
Mark Harrah 9dd5f076ea Revert "Fix sbt/sbt#676: swapped declarations and members in `ClassToAPI`."
This reverts commit beb87f2789.  It causes java/options to fail.

CC @gkossakowski
2013-02-21 20:44:54 -05:00
Grzegorz Kossakowski 5119ea2574 Mark inherited definitions in `ShowAPI`.
Mark every inherited definition with `^inherited^` marker. This helps
understanding `ShowAPI`s output.
2013-02-20 10:52:28 -05:00
Grzegorz Kossakowski f101bcd3d0 Show some of inherited members of a structure in `ShowAPI.scala`
Showing inherited members of a structure was disabled so we would not
run into cycles. To best of my knowledge, we can run into cycles only
if inherited member is `ClassLike`. We filter out those and let
anything else to be shown.
2013-02-20 10:52:27 -05:00
Grzegorz Kossakowski beb87f2789 Fix sbt/sbt#676: swapped declarations and members in `ClassToAPI`.
As described in sbt/sbt#676, arguments to `mergeMap` and `merge` methods
were swapped causing wrong structures being created for Java compiled
class files.

This commit fixes sbt/sbt#676 and makes pending test to pass now.
2013-02-20 10:52:27 -05:00
Mark Harrah 71f12fbcdb 2.9 compatibility for incremental compilation modules 2012-12-11 14:41:22 -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
Mark Harrah 1c22478edc task setting macros for :=, +=, ++=
also, bump to 2.10.0-M6
2012-11-17 20:19:24 -05: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 864580aae1 approximate type parameters and references by name
not as accurate, but simpler.
2012-05-12 23:12:29 -04:00
Mark Harrah ddcf885fb9 fresh scope for each inherited definition when tagging type variables 2012-04-28 18:58:52 -04:00
Indrajit Raychaudhuri 89678735e1 Improved implementation for `parents` accumulation for java classes
It now considers `ParameterizedType` and includes all interfaces recursively
2012-03-27 01:40:10 +05:30
Indrajit Raychaudhuri 2525eeb7e6 Ensure that `parents` for java classes have all the ancestors
Currently, only immediate parents classes are picked up for java classes.
This could be problematic, for example, in detecting Fingerprint for test frameworks.
So far, Scala types are not affected –– all the ancestors are available for them.
2012-03-25 15:44:16 +05:30
Jason Zaugg 17eeec6876 Move condition out of SameAPI.
It was tenuously relying on the caller short-circuiting with `shortcutSameSource`.
2012-03-04 21:28:01 +01:00
Jason Zaugg 72e41c3329 whitespace 2012-03-04 17:41:39 +01:00
Jason Zaugg 067917a0fb Macro def aware recompilation.
- Read macro modifier from method definition.
 - Always recompile downstream files after a file containing macro defs is recompiled.
 - Source is extended with a hasMacro attribute. Mark suggests that this might be better
   tracked in Relations, but I'm not sure how to make that change.
2012-03-04 17:35:51 +01:00
Thomas Koch 9e8c441159 missing(?) imports, fix emacs syntax highlighting
While trying to build sbt without sbt, I got compile errors claiming that
util.Random would not be a member of util. The added import statements fixed
this.

The inserted spaces in the comments in project/Sbt.scala are a work around in a
bug in emacs scala syntax highlighting.
2011-12-14 14:35:17 +01:00
Mark Harrah 82ad44a701 preserve API information needed for detecting annotations on defs. fixes #232 2011-10-19 22:23:47 -04:00
Mark Harrah f70b68d3b4 fix symmetric hashing 2011-10-09 21:48:15 -04:00
Mark Harrah c74ecb55e9 finalize hash 2011-10-05 21:04:34 -04:00
Mark Harrah e4848efcc8 store hashes of API instead of full API. fixes #21 2011-10-05 18:09:27 -04:00
Paul Phillips 528b4ed342 Limit unnecessary Array allocations from ClassToAPI.
+----------------------------------------------------------------------------+----------------+
|                                    Name                                    |  Shallow Size  |
+----------------------------------------------------------------------------+----------------+
|  +---1571683 zero length arrays xsbti.api.Annotation[]                     |    25,146,928  |
|  |                                                                         |                |
|  +---1373273 zero length arrays xsbti.api.TypeParameter[]                  |    21,972,368  |
|  |                                                                         |                |
|  +---305126 zero length arrays xsbti.api.ParameterList[]                   |     4,882,016  |
|  |                                                                         |                |
|  +---295294 zero length arrays xsbti.api.MethodParameter[]                 |     4,724,704  |
|  |                                                                         |                |
2011-09-07 13:09:53 -07:00
Mark Harrah c0a21c1524 implement shortcut for API equality checking, fixes #18 2011-06-01 02:19:46 -04:00
Mark Harrah 58d9f3b0a0 fix structural type comparison 2011-05-25 22:44:22 -04:00
Mark Harrah 24dfb69400 an annotation can reference a non-simple type, fixes #24 2011-05-23 18:40:03 -04:00
Mark Harrah 1d36be9b00 properly handle nested class cycles in Java sources, fixes #22 2011-05-21 21:16:18 -04:00
Mark Harrah 9dec02ee51 fix analysis of Java sources being overwritten 2011-04-26 21:19:56 -04:00
Mark Harrah d719c7d6a9 add missing debug case for SameAPI 2011-03-11 16:55:23 -05:00