Commit Graph

3034 Commits

Author SHA1 Message Date
Paul Berry b715b97147 Don't visit named argument labels when computing constant dependencies.
This fixes some crashes with the new task model.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1178203002.
2015-06-11 10:36:36 -07:00
Paul Berry c03b8fe451 Ensure that prefix?.loadLibrary() generates the proper compile-time error.
loadLibrary() is special-cased in analyzer, so we need special-case
code to make sure that it can't be invoked using "?.".

Fixes #23463.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1177833002.
2015-06-10 14:43:46 -07:00
Paul Berry 2f610a3ff5 Report a compile-time error if a const field is multiply initialized.
This CL makes analyzer consistent with the VM and the spec, by
producing a compile-time error for code such as:

    class C {
      final x = 1;
      const C() : x = 2;
    }
    main() {
      const C();
    }

Note that Dart2js also produces an error in this circumstance, but its
error is too general (the error should only be produced if the const
constructor is invoked using "const"; if the const constructor is
invoked using "new", or is not invoked at all, it should only be a
warning).  See #23618.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1175073002.
2015-06-10 14:02:43 -07:00
Brian Wilkerson f2954e5237 Fix a test to work with the new task model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1175843003.
2015-06-10 09:05:41 -07:00
Paul Berry 4e36247eea In constant evaluation, consistently handle const depending on non-const.
It is a compile-time error for a constant value to depend on a
non-constant value (or a non-constant constructor), however the
analyzer still needs to be able to handle it.

This CL adjusts the ConstantEvaluationEngine so that it consistently
reports all the dependencies of a given constant (whether those
dependencies are constant are not), but which is tolerant of being
asked to compute a constant value of a non-constant.

Fixes test failures with the new task model enabled.  No behavioral
change with the new task model disabled.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1167413005.
2015-06-09 13:48:43 -07:00
Paul Berry fc83ce5ba9 Fix analyzer's handling of import prefixes not followed by '.'.
If 'p' is an import prefix, then 'p = ...' is treated as synonymous
with 'this.p = ...', and 'p()' is treated as synonymous with
'this.p()'.  In all other circumstances where 'p' is not followed by
'.', the spec calls for a compile time error.

Previous to this CL, 'p' not followed by '.' was being treated as
synonymous with 'this.p' under all circumstances.  This CL brings
analyzer in line with the spec, and updates the tests in
tests/language accordingly.

The VM and Dart2js currently fail to implement the compile-time error
properly.  See issues #23611 and #23612.

Fixes issue #23461.

R=scheglov@google.com

Review URL: https://codereview.chromium.org//1173523002.
2015-06-09 13:38:53 -07:00
Konstantin Shcheglov da82786e2a Don't run HTML tests with the new task model.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1174553003.
2015-06-09 13:21:33 -07:00
Konstantin Shcheglov 51c8a30440 Fix for comment references tests.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1173633002.
2015-06-09 08:52:20 -07:00
Konstantin Shcheglov 25620e2e59 Remove extra CompileTimeErrorCode.DUPLICATE_DEFINITION.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1170863002
2015-06-08 22:58:32 -07:00
Konstantin Shcheglov b916cbffa4 Don't run old implementation tests with 'useTaskModel == true'.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1159153004
2015-06-08 11:03:35 -07:00
Brian Wilkerson 7230007d52 Fix several tests when the new task model is enabled
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1164223002
2015-06-07 19:31:04 -07:00
Brian Wilkerson add5a6910d Remove many explicit references to AnalysisContextImpl and enable testing of the new task model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1150863007
2015-06-06 08:30:38 -07:00
Konstantin Shcheglov 811877df42 Invalidate resolution of analysisOptions/sourceFactory changes.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1167483004
2015-06-05 14:09:12 -07:00
Brian Wilkerson ba4523df1a Add correct test for issue 23523
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1166503004
2015-06-05 09:20:54 -07:00
Brian Wilkerson 5d2cbd5d55 Added test for issue 23523
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1166653006
2015-06-04 13:34:13 -07:00
Brian Wilkerson 56be513cf9 Add isExternal accessor to element model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1158793004
2015-06-04 12:38:31 -07:00
Paul Berry 62f7ac8c5d Fix handling of nested typedefs (for real this time).
This is a re-fix of dartbug.com/21912, which I previously fixed
incorrectly.  Previously, our approach to avoiding infinite loops when
comparing types was to maintain a set of typedefs being expanded on
the stack, and prune the comparison whenever an attempt was made to
expand a typedef that was already being expanded.  However, this was
too strict, since there are legal (non-circular) types which invole
expanding a given typedef in reentrant fashion; we can't prune these
types without producing incorrect semantics.  An example (from the bug
report) is the type of f in the code below:

    typedef T Function2<S, T>(S z);
    Function2<Function2<A, B>, Function2<B, A>> f;

The solution is to maintain the list of typedefs being expanded inside
each FunctionTypeImpl object (and InterfaceTypeImpl object) rather
than on the stack during the comparison; this allows us to distinguish
the situations where we need to prune (those having to do exclusively
with expansion of a typedef) from the situations where we shouldn't
prune (those having to do with substitution of a type parameter).

A beneficial side effect of this change is that code that interacts
with types no longer needs to worry about typedef circularities, since
the circularities will automatically be pruned while exploring the
type definitions.  This simplifies the implementation of
isAssignableTo, isSubtypeOf, operator==, and hashCode.  (Note,
however, that code still needs to cope with circularities in the
inheritance hierarchy).

BUG=dartbug.com/21912
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1143003007
2015-06-01 12:45:27 -07:00
Konstantin Shcheglov f1d4ef9164 Issue 23409. Don't set 'propagatedType' in (vs. after) 'name is Type'.
This fixes the corresponding 'Extract Method' issue.

R=brianwilkerson@google.com
BUG=https://code.google.com/p/dart/issues/detail?id=23409

Review URL: https://codereview.chromium.org//1161343002
2015-06-01 12:40:30 -07:00
Konstantin Shcheglov 9dc5bc79f1 Issue 23518. Match prefixes of prefixed types.
R=brianwilkerson@google.com
BUG= https://code.google.com/p/dart/issues/detail?id=23518

Review URL: https://codereview.chromium.org//1149953005
2015-06-01 09:27:29 -07:00
Brian Wilkerson fb983067bd Rename Element.node
Review URL: https://codereview.chromium.org//1163573002
2015-05-28 08:27:23 -07:00
Konstantin Shcheglov dbd2463d6d Don't schedule LIBRARY_ERRORS_READY for libraries that should not be analyzed.
This helps to save about 1500 ms, or about 10% on the analyzer project.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1155473003
2015-05-24 10:00:21 -07:00
Konstantin Shcheglov 4ca0c7acbb Adapt the existing incremental resolution implementation to the new model.
This is hopefully a temporary implementation, to be used until we have a
proper task-based version. Otherwise the new task model is too slow to
conveniently dogfood it.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1144023009
2015-05-23 16:56:01 -07:00
Paul Berry e2366de610 Generate the proper error when a constant refers to itself.
BUG=dartbug.com/23490
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1131383008
2015-05-19 19:37:19 -07:00
Konstantin Shcheglov 4936eb8d5d Fix for 'Create part' Quick Fix.
1. NonExistingSource.modificationStamp should return -1.
2. NonExistingSource.fullName should be always an absolute path, not a URI.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1135073004
2015-05-18 11:55:23 -07:00
Brian Wilkerson 1a3e349409 Handle type parameters correctly when generating hints (issue 23243)
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1142853002
2015-05-18 10:41:11 -07:00
scheglov@google.com 6e25226a0d Issue 23444. Use ConstructorMember(s) for super constructor fixes.
R=brianwilkerson@google.com
BUG= https://code.google.com/p/dart/issues/detail?id=23444

Review URL: https://codereview.chromium.org//1140963002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45765 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-13 16:13:09 +00:00
scheglov@google.com dfd26c038b Create ChangeNotice(s) and set parsed/resolved units.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1138853003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45736 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-12 13:52:20 +00:00
paulberry@google.com 0e4d3d0190 Unify evaluation of annotations with evaluation of other constants.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1134133002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45713 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-11 19:35:26 +00:00
scheglov@google.com 88973df145 Add DartWorkManager to manage Dart-specific results computation scheduling.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1132893003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45677 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-09 23:22:21 +00:00
brianwilkerson@google.com 81e474c43e Clean up many generated constructors
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1131423002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45676 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-09 19:06:12 +00:00
paulberry@google.com b901fbcf95 Add a "librarySource" field to CompilationUnitElementImpl.
This fixes a dependency problem in ComputeConstantDependenciesTask.
Prevously it used element.library.source to get access to the library
source, but this created an implicit dependency on LIBRARY_ELEMENT1
(since element.library is null if the library element hasn't been
built yet).  There was no way to make that dependency explicit since
previous to this change, the CompilationUnitElement did not store
enough information to determine what library it was part of until
after the library element had been created.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1125123006

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45674 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-09 01:19:17 +00:00
paulberry@google.com 728e9b3a9e Create a task in the new task model to compute constant dependencies.
This is the first of several planned tasks for constant evaluation.

R=brianwilkerson@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org//1131953004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45624 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-08 00:36:45 +00:00
scheglov@google.com 61a371476b Remove unused InternalAnalysisContext.addSourceInfo().
The analysis cache is now accessible, if we will ever need this feature again.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1131063004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45616 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-07 20:17:13 +00:00
paulberry@google.com 7040257579 Store elements in the constant eval dependency graph rather than AST nodes.
This paves the way for constant evaluation to be integrated into the
new task model, since the new tasks for constants will use elements as
their targets.

Since the element model makes a distinction between constructor
members and constructor elements, we have to be careful to be
consistent about what kinds of elements are stored in the dependency
graph.  We always store constructor elements in the dependency graph.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1129143003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45611 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-07 19:38:37 +00:00
scheglov@google.com 9aeccc0d2f Get AnalysisCache from InternalAnalysisContext.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1124113004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45609 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-07 19:12:42 +00:00
scheglov@google.com a3366361de Cache flushing implementation for the task model.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1133513003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45597 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-07 15:50:13 +00:00
brianwilkerson@google.com 1124eaacd8 Rename EMPTY_ARRAY to EMPTY_LIST
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1127183003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45579 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-06 23:47:59 +00:00
paulberry@google.com dc04ae1271 Remove const instance creation expressions from the dependency graph.
Instead of treating them as separate nodes in the dependency graph,
evaluate them directly in the ConstantVisitor at the time they are
needed.  This makes the dependency graph more uniform, since
everything in it is now associated with an element.  This should make
it easier to adapt constant evaluation to the new task model.

In order to avoid introducing regressions with this change, I had to
implement proper reporting of cycles in compile-time constants.
(Previously, this was unimplemented but worked correctly in most cases
by luck.)

Note: technically this constitutes a breaking API change, since it
removes the field constantHandle and the getter evaluationResult from
the InstanceCreationExpression class.  I believe these members are not
used outside of analyzer, so I'm leaving the analyzer version number
as is.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1124733008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45541 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-05 21:46:25 +00:00
paulberry@google.com 3d770ab87a Create a class for evaluating const instance creation expressions.
Previously the methods for evaluating const instance creation
expressions were all in the ConstantValueComputer class.  Moving them
to their own class allows for the possibility of evaluating them in
the ConstantVisitor, which in a future CL should allow us to avoid
making these expressions part of the const dependency graph.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1129563002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45533 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-05 17:47:35 +00:00
paulberry@google.com fe50987b74 Move validation logic for constant evaluation into its own class.
This will help facilitate some refactoring of constant evaluation that
needs to be done in order to prepare it for the new task model.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1121313004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45527 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-05 14:22:53 +00:00
paulberry@google.com f2b84f9988 Fix constant evaluation logic for String.length.
Previously, we used static resolution to determine whether
String.length was being referred to, causing incorrect results in the
presence of bad type annotations.  Also, we were missing a null check,
causing constant evaluation to crash if an attempt was made to take
the length of a constant that couldn't be evaluated.

BUG=dartbug.com/23383
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1124433007

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45524 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-05 13:07:21 +00:00
paulberry@google.com a924c66fc5 Add a flag to the element model to identify mixin applications.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1120623003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45495 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 17:00:34 +00:00
paulberry@google.com 7138d01444 In constant evaluation, handle final vars initialized at declaration site.
Previously final variables initialized at the declaration site
would simply be ignored, causing some checked-mode compile time
errors to be missed, and causing the analyzer to produce
incorrect values for any such constants.

BUG=dartbug.com/23292
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org//1099953004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45494 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 16:21:54 +00:00
paulberry@google.com 34d8b562be Make sure to visit function annotations in ElementBuilder.
Since r44861, ElementBuilder is responsible for creating the
ConstantInstanceCreationHandle objects associated with
InstanceCreationExpressions.  Since InstanceCreationExpressions may
appear inside annotations, we must make sure the ElementBuilder visits
all annotations.  Previous to this change, it didn't visit function
annotations.

BUG=dartbug.com/23354
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1125613003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45489 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-04 13:25:08 +00:00
scheglov@google.com f92f340ab8 Remove AnalysisContext.refactoringUnsafeSources.
It is not used anyway.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org//1113423003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45474 260f80e4-7a28-3924-810f-c04153c831b5
2015-05-01 20:36:51 +00:00
brianwilkerson@google.com 5c5bc38ac3 Initial re-write of analysis context for the new task model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1053673008

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45284 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-20 15:00:01 +00:00
brianwilkerson@google.com 9bb1c7ff18 Rename EMPTY_ARRAY to EMPTY_LIST in element model
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1061993003

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45212 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-16 15:54:10 +00:00
scheglov@google.com b1dd0f8843 Fix another false positive for not used function type alias.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org//1061003004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45178 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 19:45:49 +00:00
brianwilkerson@google.com c699a9b79d Stop generating error when ignoring function bodies (issue 23207)
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1059753005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45172 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 16:11:12 +00:00
brianwilkerson@google.com d2af892e6a Capture annotations on enums (issue 23071)
R=scheglov@google.com

Review URL: https://codereview.chromium.org//1087223002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@45167 260f80e4-7a28-3924-810f-c04153c831b5
2015-04-15 14:33:39 +00:00