Commit Graph

3034 Commits

Author SHA1 Message Date
Brian Wilkerson ade0e4c5cd More aggressively fail when associating an existing element model with an AST (issue 25678).
The problem we're seeing is that mismatches between the element model and the AST are causing exceptions to be thrown that are not being handled by the normal exception handling in AnalysisTask. This causes the exception to be converted into an AnalysisException, which will cause the AST structure to be marked as being in ERROR, and it will be re-computed later after a change invalidates it.

This also causes the exception to be thrown more frequently to prevent mismatches from being ignored (and to report the mismatch earlier).

This only checks that every node in the AST has an element associated with it. The next step (in a future CL) is to ensure that the opposite problem doesn't exist (that is, that all elements are associated with a node).

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1669383002 .
2016-02-05 12:28:48 -08:00
Paul Berry c43622e897 Use ElementAnnotation as the ConstantEvaluationTarget for annotations.
Previously, we had a special class,
ConstantEvaluationTarget_Annotation, for this purpose.  It held on to
a the AST node for the annotation.  This was bad because it meant that
the presence of any ConstantEvaluationTarget_Annotation referring to a
given compilation unit would keep the entire compilation unit's AST in
memory.

Now we copy just the portions of the AST we need into
ElementAnnotation, just as we do for all other constant evaluation
targets.  In addition to saving memory, this paves the way for
supporting annotations in summaries, by making it possible to compute
the constant value of an annotation without having to consult the full
AST.

Fixes #25285.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1665353002 .
2016-02-04 15:22:40 -08:00
Paul Berry 2cdec8fd10 Make DeclarationResolver re-associate Annotations with ElementAnnotations.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1667963005 .
2016-02-04 14:09:12 -08:00
Paul Berry 1b4e048856 Test that ElementBuilder handles DefaultFormalParameter properly.
These test cases were accidentally left out of commit
5024882905.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1665283002 .
2016-02-04 14:04:51 -08:00
Konstantin Shcheglov 098d67330b Issue 25657. Update offsets of cloned constant initializers.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25657

Review URL: https://codereview.chromium.org/1667023002 .
2016-02-04 10:04:01 -08:00
Paul Berry 5024882905 Create ElementAnnotation objects prior to resolution.
This is a prerequisite to fixing #25285
(ConstantEvaluationTarget_Annotation consumes too much memory,
shouldn't exist).  By creating the ElementAnnotation objects early, we
will be able to refer to them from the ConstantFinder; this will allow
us to use the ElementAnnotation objects as constant evaluation
targets.

Note: there is a small semantic change.  Previously, Element.metadata
only contained ElementAnnotation objects for annotations that were
successfully resolved.  Now, it contains ElementAnnotation objects for
all annotations.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1668483003 .
2016-02-04 05:21:34 -08:00
Konstantin Shcheglov 0232570f44 Clone and link all tokens in AstCloner.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1660873003 .
2016-02-03 21:31:28 -08:00
Paul Berry 36f5c1eeb4 Revert "Create ElementAnnotation objects prior to resolution."
This reverts commit 3977c9f227.

The aforementioned commit broke co19 tests involving annotated `part of`
directives.  It turns out that we can't create the ElementAnnotation
objects for annotated `part of` declarations in
BuildDirectiveElementsTask, because BuildDirectiveElementsTask is only
ever targeted at libraries, therefore it only creates ElementAnnotation
objects for annotated directives in defining compilation units.

I will follow up with a CL that builds all the ElementAnnotation objects
in BuildCompilationUnitElementTask, which runs on all compilation units.

TBR=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1665683002 .
2016-02-02 17:55:01 -08:00
Brian Slesinsky 54ee3eefd1 Fix memory leak in incremental resolver
Moving an element that's in the AnalysisCache causes
it to leak because operator== and hashCode are based
on its location.

To make sure we detect this, added a "frozen" flag to
Element. It's set when the element is used as a key
in the AnalysisCache.

Cleanup: in IncrementalResolver, make all fields
final that are never changed.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1650873002 .
2016-02-02 15:40:33 -08:00
Paul Berry 3977c9f227 Create ElementAnnotation objects prior to resolution.
This is a prerequisite to fixing #25285
(ConstantEvaluationTarget_Annotation consumes too much memory,
shouldn't exist).  By creating the ElementAnnotation objects early, we
will be able to refer to them from the ConstantFinder; this will allow
us to use the ElementAnnotation objects as constant evaluation
targets.

Note: there is a small semantic change.  Previously, Element.metadata
only contained ElementAnnotation objects for annotations that were
successfully resolved.  Now, it contains ElementAnnotation objects for
all annotations.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1660713002 .
2016-02-02 14:43:01 -08:00
Paul Berry a7a028737d Move ElementBuilder and CompilationUnitBuilder into builder.dart.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1659973002 .
2016-02-02 12:27:03 -08:00
Paul Berry 87c6790bb9 Add tests demonstrating bug #25605.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1650783002 .
2016-01-31 05:43:02 -08:00
Bob Nystrom 434f5bc922 Implement the spec's notion of LUB for function types.
Fixes #23381.

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

Review URL: https://codereview.chromium.org/1648063002 .
2016-01-29 10:37:58 -08:00
Brian Wilkerson 18482981d3 Fix an exception caused by malformed code
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1648923003 .
2016-01-29 10:26:30 -08:00
Konstantin Shcheglov 2546e179a9 Make constant map literal ordered.
Plus couple fixes for spelling problems.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1643253002 .
2016-01-29 09:31:03 -08:00
Konstantin Shcheglov df5d6bd6e1 Move more constant tests to constant_test.dart file.
I found out that we use HashMap for constant map literals.
But then I realized that I we could move more tests into the right
place.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1647183002 .
2016-01-29 08:58:41 -08:00
pq e902b07ed4 Engine test fix to keep up with SourceFactory changes.
BUG=
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1645173002 .
2016-01-28 12:57:45 -08:00
Bob Nystrom 4af641864f A missing enum case in a switch is a warning, not a compile-time error.
Fixes #25576.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1644683002 .
2016-01-28 11:12:25 -08:00
Brian Wilkerson b33f1380d0 Add tests, including test for issue
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1647613002 .
2016-01-27 12:44:14 -08:00
Paul Berry 4e86a006db Stop precomputing ClassElement.isValidMixin.
Previously, we would precompute the value of ClassElement.isValidMixin
and store it in the Modifier.MIXIN.  But this didn't really save any
time, because (a) isValidMixin isn't used inside analyzer, and (b) it
is easily derivable from other information already present in the
element model.

Also, we were computing it incorrectly when the `--supermixin` flag
was present.

This CL replaces the precomputation logic with a direct implementation
in ClassElement.isValidMixin which is correct regardless of the
presence of the `--supermixin` flag.  The tests are beefed up so that
(a) they validate correct behavior for both states of the flag, (b)
they validate correct behavior in the presence of factory
constructors, and (c) they validate that the behavior of
`isValidMixin` is consistent with the error messages produced by the
analyzer.

In addition to fixing bugs, the removal of Modifier.MIXIN means we
have one less piece of information to store in summaries.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1635063003 .
2016-01-26 07:29:48 -08:00
Brian Slesinsky ccf3870ffc final fields shouldn't be dependencies of const variables
(They are only dependencies of const constructors.)

This was causing bogus error messages to appear
when a const expression mistakenly references
a final field.

BUG=https://github.com/dart-lang/sdk/issues/25526
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1620963003 .
2016-01-25 15:53:41 -08:00
Brian Slesinsky 28ecd1bbef Oops, move ReferenceTest to constant_test.dart as well
BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1623673003 .
2016-01-25 13:28:05 -08:00
Brian Wilkerson dd0c42cb72 Moved the AST related tests to their new locations
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1612933006 .
2016-01-23 09:45:01 -08:00
Konstantin Shcheglov 0025a8383e Copy 'ConstructorName.staticElement' in ConstantAstCloner.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1625473004 .
2016-01-22 15:19:06 -08:00
Brian Slesinsky 001f64b564 print nicer errors for a const dependency graph failure
BUG=
R=brianwilkerson@google.com, paulberry@google.com

Review URL: https://codereview.chromium.org/1618103002 .
2016-01-22 14:47:18 -08:00
John Messerly 9a4b1c36ce fixes #25482, flatten futures in strong mode so Future.then works
Also fixes https://github.com/dart-lang/dev_compiler/issues/228

A few tweaks were made to the propagatedType inference for Future.then:
* only record type if better than static type
* only go down this path when strong mode is off

also renames tests: test_pseudoGeneric to test_genericMethod.

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

Review URL: https://codereview.chromium.org/1609093003 .
2016-01-22 13:29:58 -08:00
Brian Slesinsky 771fea4502 move constant tests to constant_test.dart
BUG=
R=brianwilkerson@google.com, paulberry@google.com

Review URL: https://codereview.chromium.org/1616743006 .
2016-01-22 12:44:15 -08:00
Konstantin Shcheglov 068b886543 Disable incremental resolution for constructor parameter names changes.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1620453002 .
2016-01-21 14:33:42 -08:00
Konstantin Shcheglov b78decfa8f Issue 25522. Insert a synthetic '>' for incomplete type arguments.
If we don't do this and insert 'f' instead, later when we attempt to
search 'f' by its offset we find the type instead of the identifier 'f'.

R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25522

Review URL: https://codereview.chromium.org/1615963003 .
2016-01-21 13:03:24 -08:00
Konstantin Shcheglov 0a495243c6 Validate that int values that we write to summaries are >= 0.
Also make tweaks for TestTypeProvider to ensure that this is true.

R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1605763007 .
2016-01-20 13:38:10 -08:00
Konstantin Shcheglov 203e16919a Issue 25515. Don't incrementally resolve if a constructor initializer is changed.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25515

Review URL: https://codereview.chromium.org/1606103003 .
2016-01-20 08:49:29 -08:00
Konstantin Shcheglov 23e9fbcf30 Issue 25514. Harden parents validation in incremental resolver.
R=brianwilkerson@google.com, skybrian@google.com
BUG= https://github.com/dart-lang/sdk/issues/25514

Review URL: https://codereview.chromium.org/1605263002 .
2016-01-20 08:02:07 -08:00
Konstantin Shcheglov 07f8831bc2 Serialize constant initializers.
No implementation for element references in this CL.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1602203004 .
2016-01-19 13:42:51 -08:00
Brian Wilkerson 21ecb14548 Clean-up imports
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1602803002 .
2016-01-18 15:42:16 -08:00
Konstantin Shcheglov 78aad4c282 Fix the build - add the new field.
TBR

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1598183003 .
2016-01-17 09:41:21 -08:00
Brian Wilkerson d116322f7d Do not produce hint on constructor when class is deprectated (issue 25503)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1598773004 .
2016-01-16 15:09:56 -08:00
Konstantin Shcheglov 6b56451788 Issue 25504. Fix for ignoring expression bodies in incremental resolver.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25504

Review URL: https://codereview.chromium.org/1584653007 .
2016-01-15 12:20:49 -08:00
Dan Rubel b7303a3409 plumb through enableAsync
and mock async library elements if enableAsync is false

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1591653003 .
2016-01-15 14:15:02 -05:00
John Messerly 9da8970cdf fix #25486, promote from dynamic in strong mode
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1585323003 .
2016-01-14 16:19:27 -08:00
John Messerly 9098ae50ae fix #25425, more inference of generic methods
this adds support for function expr invocation, as well as other element types besides executable elements

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

Review URL: https://codereview.chromium.org/1586813002 .
2016-01-14 13:27:34 -08:00
John Messerly 724492ca82 fixes #25340, propagatedType now finds the instantiated generic method's return type
R=brianwilkerson@google.com, leafp@google.com

Review URL: https://codereview.chromium.org/1582863003 .
2016-01-14 13:20:13 -08:00
John Messerly 154959c762 fixes #25407, generic list and map literal type comments
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1589663002 .
2016-01-14 13:18:59 -08:00
danrubel 559fb01244 assert isAsynchronous and isGenerator false if parseAsync is false
and fix ASYNC_NOT_SUPPORTED error code

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

Review URL: https://codereview.chromium.org/1584823003 .
2016-01-14 14:52:23 -05:00
Brian Wilkerson 1e9326d13f Add tests for computation of constant expressions involving ??
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1589043002 .
2016-01-14 10:55:21 -08:00
Konstantin Shcheglov 9484bfe1c9 Issue 25064. Incrementally resolve comments only if both are documentation.
R=brianwilkerson@google.com, skybrian@google.com
BUG= https://github.com/dart-lang/sdk/issues/25064

Review URL: https://codereview.chromium.org/1581293002 .
2016-01-14 08:38:37 -08:00
Konstantin Shcheglov 0d8a31e0a6 Create LibraryElement.loadLibrary during resynth.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1583613002 .
2016-01-13 09:35:37 -08:00
John Messerly 351ccc586f fix generic function expressions, part of #25175
R=leafp@google.com

Review URL: https://codereview.chromium.org/1579303002 .
2016-01-12 16:04:57 -08:00
Brian Slesinsky 5cc87405aa Don't log stack trace for a bad package URL in a source file.
BUG=https://github.com/dart-lang/sdk/issues/25367
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1572073003 .
2016-01-11 15:53:49 -08:00
John Messerly bc7843b025 fix #25280, treat setters as returning void in strong mode
this gives better checking for an incorrect "return" in a setter

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1531313002 .
2016-01-11 14:42:48 -08:00
John Messerly 8c1e862a90 support generic methods in FunctionExpressionInvocation node
fixes part of #25175

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

Review URL: https://codereview.chromium.org/1561233003 .
2016-01-11 12:56:07 -08:00