Commit Graph

7128 Commits

Author SHA1 Message Date
Paul Berry 869caf052b Add summary support for annotations.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1672413002 .
2016-02-08 07:05:11 -08:00
Paul Berry 079e8a1d62 Fix confusion between parameters vs arguments in parser.
There are two changes:

1. Modify `_isPeekGenericTypeParametersAndOpenParen` to call
`_skipTypeParameterList` instead of `_skipTypeArgumentList`.  This
fixes parsing of generic function declarations like `f<@a T>() {}`,
which previously couldn't be parsed because `<@a T>` isn't a valid
type argument list.

2. Rename `_isLikelyParameterList` to `_isLikelyArgumentList` to
reflect how it is actually used (and what it actually does).  This is
no user-visible effect.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1674043002 .
2016-02-07 10:42:32 -08:00
Paul Berry c55194bd9b Remove shouldCompareConstValues.
Now that summaries fully support constant values, this boolean isn't
needed.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1671413003 .
2016-02-06 10:48:43 -08:00
John Messerly 32f1c26f08 restore inline JS builtin test
This test was accidentally removed in:
https://github.com/dart-lang/sdk/commit/eb28d6e7b38fe0b16e28c82719c93b469ca7ca9b

R=vsm@google.com

Review URL: https://codereview.chromium.org/1672923002 .
2016-02-05 15:43:16 -08:00
John Messerly e3a6a5a0d9 remove unused locals/members/test functions
Some of these slipped in with the CL I just sent, a few others existed previously. I'd been sort of ignoring the hint window.

R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1673933002 .
2016-02-05 15:40:31 -08:00
John Messerly c5f6ab52c8 improve debugging of strong mode checker/inference tests
Refactored along the lines of a previous discussion (https://codereview.chromium.org/1632113002/) ... I wasn't able to go all the way to reflective tests in the budget of time/automated refactoring, but I was able to make most of the improvements.

R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1673843003 .
2016-02-05 15:22:36 -08:00
Konstantin Shcheglov 2e8943aa2e Resynthesize default parameter values.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1671293002 .
2016-02-05 15:13:23 -08:00
Konstantin Shcheglov c42d001598 Serialize initializers for final fields.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1679493002 .
2016-02-05 15:11:45 -08:00
Konstantin Shcheglov a80a098330 Resynthesize top-level function references.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1670403002 .
2016-02-05 13:34:43 -08:00
Paul Berry 1995031845 Enforce LinkedReference.dependency == 0 for contained entities.
This was always the intention, but it didn't wind up getting
implemented as intended due to lack of testing.  This CL adds testing
and fixes the implementation.

Note that there is no effect on resynthesis, since resynthesis only
consults LinkedReference.dependency for top level entities.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1670353002 .
2016-02-05 13:19:50 -08:00
Paul Berry f1ed41c576 Test summarizing of constants that refer to top level functions.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1674793002 .
2016-02-05 12:49:09 -08:00
Konstantin Shcheglov a20b1b00f9 Include default parameter values into summary.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1677683002 .
2016-02-05 12:42:20 -08:00
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 29e7d0177b Resynthesize 'String.length' getter references in constants.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1668983002 .
2016-02-04 13:11:22 -08:00
John Messerly 86a366403e fixes #25640, errors on function downcasts when we know it's an exact type
R=vsm@google.com

Review URL: https://codereview.chromium.org/1663533002 .
2016-02-04 10:33:19 -08:00
John Messerly 09403720f8 fixes #25668, correctly infer generic method override
R=vsm@google.com

Review URL: https://codereview.chromium.org/1668683002 .
2016-02-04 10:20:00 -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 3057754843 Use summary IDL file for interface classes.
This CL makes a small change to the format of the summary IDL file:
instead of containing classes with fields, it now contains classes
with getters.  This allows the classes in the IDL file to be directly
used as interface classes, which makes code navigation much smoother.

Since the IDL file is now being used directly by the code, it has been
relocated to pkg/analyzer/lib/src/summary/idl.dart.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1667723002 .
2016-02-03 08:57:44 -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
Konstantin Shcheglov 678048132b Resynthesize generic class instance creations.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1660663002 .
2016-02-02 14:27:28 -08:00
John Messerly eb28d6e7b3 fix #25619 - downward inference on generic function tear-offs
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1644403005 .
2016-02-02 13:03:54 -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
Konstantin Shcheglov c4493869ca Serialize constant instance creation of generic classes.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1658253002 .
2016-02-02 10:11:38 -08:00
Konstantin Shcheglov 3099008a5e Resynthesize instance creation expressions.
Only non-generic classes for now.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1657033002 .
2016-02-01 14:38:57 -08:00
Paul Berry 24b5df4dcc Use LinkedDependency.parts to find part URIs during resynthesis.
Now we can resynthesize a given library without having to consult any
summaries other than the linked summary for the library itself and the
unlinked summaries for all its compilation units.  All other summaries
are consulted only on demand if the information in them is needed.
Tests are updated to validate this.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1653163003 .
2016-02-01 14:32:20 -08:00
John Messerly 88dbb006c5 fixes inferring () -> <bottom> in strong mode
This fixes https://github.com/dart-lang/dev_compiler/issues/47

R=vsm@google.com

Review URL: https://codereview.chromium.org/1649523002 .
2016-02-01 13:30:23 -08:00
Paul Berry b3e588e640 Check proper resynthesis of type parameters of generic methods.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1656033002 .
2016-02-01 13:10:48 -08:00
Konstantin Shcheglov eff97b738e Resynthesize static method references.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1658723005 .
2016-02-01 12:58:01 -08:00
Konstantin Shcheglov a568af080e Resynthesize top-level and class static property access references.
Class static methods have some complications related to propagated
types, so I will do it after this CL.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1652183002 .
2016-02-01 11:43:17 -08:00
Konstantin Shcheglov a4711db5f4 Resynthesize type references.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1650833002 .
2016-02-01 09:18:00 -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
Konstantin Shcheglov eb4a056948 Verify AST instead of constant values.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1651653002 .
2016-01-29 14:55:56 -08:00
Paul Berry 8da962e6a3 Test and fix a few more corner cases of summarizing type inference.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1643403002 .
2016-01-29 13:47:01 -08:00
Paul Berry 9e7b8daf83 Add the ability to summarize inferred types based on function-typed parameters.
There may still be bugs related to generic types.  I will follow up
with more tests (and fixes if necessary) in further CLs.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1647253002 .
2016-01-29 13:12:15 -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
Paul Berry db4acee8c3 Rename ReferenceKind.constField and referenceKind.staticMethod.
These will be re-used when summarizing inferred types, and they won't
necessarily refer to things that are const/static.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1646363002 .
2016-01-29 10:34:12 -08:00
Konstantin Shcheglov a110b6c691 Resynthesize typed constant lists and maps.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1643283002 .
2016-01-29 10:28:05 -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
pq 9b1fa223a8 Embedded libs key rename to defuse server landmine.
1.13 stable builds of the SDK contain a version of server that fails catastrophically when analyzing source that imports packages that define embedded libraries. Since we can't pragmatically require more recent SDKs for flutter development we have been prevented from landing embedded libs in the flutter engine.  By renaming the key we use to identify contributed libraries, this change avoids the issue.  Old versions of server will simply ignore the new key and new ones will process it properly.  Win-win!

BUG=
R=danrubel@google.com

Review URL: https://codereview.chromium.org/1643023002 .
2016-01-29 09:52:04 -08:00
Konstantin Shcheglov 371922dc67 Resynthesize untyped List / Map.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1642993003 .
2016-01-29 09:39:17 -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
Konstantin Shcheglov a3b870d8ec Resynthesize binary and prefix expressions.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1649873002 .
2016-01-28 14:40:02 -08:00