Commit Graph

8489 Commits

Author SHA1 Message Date
Konstantin Shcheglov 84cb715bdd Resynthesize invalid constants as unresolved identifiers.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1681513003 .
2016-02-08 12:26:54 -08:00
Paul Berry 68d3b46c6a Fix summarization of unqualified references to class members.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1675393002 .
2016-02-08 12:14:44 -08:00
Konstantin Shcheglov 0a3b938409 Add UnlinkedConst.isValid and set it during summarizing.
Several final fields in SDK have not valid constant expression
initializers, which is OK because the enclosing classes don't have
constant constructors. However we were throwing exceptions and failing
building SDK summaries.

Alternatively we could just ignore final field initializers in classes
without a constant constructor. But it seems to me that we need to
catch exceptions anyway, just in case of invalid code.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1674073002 .
2016-02-08 09:11:10 -08:00
Konstantin Shcheglov 46850c69ab Summarize constructor initializers.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1678753002 .
2016-02-08 08:30:58 -08:00
William Hesse b201036951 Remove import of AnalysisException from wrong library.
The class comes from generated/java_engine.dart, not generated/engine.dart

BUG=
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1680703002 .
2016-02-08 17:27:24 +01:00
Vijay Menon 8efb58ae20 Make error message deterministic
We are tracking/regressing errors and warnings on the DDC bots, and keep getting spurious diffs like this:
  https://codereview.chromium.org/1649583002/diff/1/test/codegen/expect/collection/wrappers.txt
This change should keep things sorted.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1680683002 .
2016-02-08 07:27:54 -08:00
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
Brian Wilkerson a9d0e2bf76 Add comments to public libraries
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1672383002 .
2016-02-06 16:27:54 -08:00
Konstantin Shcheglov 010e0e6b71 Separate CONSTANT_EXPRESSION_RESOLVED flag from RESOLVED_UNITx.
We only need to know that we can eveluate the constant.
In non-summaries world we have the resolved unit anyway.
But in case of summaries we don't, but we know that all the constant
expressions are resynthesized as resolved (even if lazily).

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

Review URL: https://codereview.chromium.org/1673913002 .
2016-02-05 18:04:24 -08:00
Bob Nystrom ed609b7c41 Remove some unneeded getters.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1673873003 .
2016-02-05 16:11:07 -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
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
Brian Wilkerson 5e615e9c31 Check that all elements are associated with nodes when resolving using an existing element model
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1679433003 .
2016-02-05 14:25:31 -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
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
Konstantin Shcheglov d4d840e598 Add name/offset constructors for default parameter elements.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1676573002 .
2016-02-05 12:40:08 -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 5ff6f9225b Fix error plumbing in WorkItem
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1673433002 .
2016-02-04 14:18:52 -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
Bob Nystrom 6c3cf3e02c Refactor strong mode's function type isSubtypeOf() to use the same structural walking code as spec mode function types.
R=jmesserly@google.com, paulberry@google.com

Review URL: https://codereview.chromium.org/1663353002 .
2016-02-04 13:31:38 -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
Konstantin Shcheglov 217cd8181b Remove unused READY_RESOLVED_UNIT10 and READY_RESOLVED_UNIT11.
...as well as the corresponding tasks that produce them.

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

Review URL: https://codereview.chromium.org/1668993002 .
2016-02-04 13:09:42 -08:00
pq 37767eff86 Hooks for injecting embedder resolver providers.
BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1666573006 .
2016-02-04 11:03:43 -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
Florian Loitsch 6468ba5022 Share the first error messages.
R=brianwilkerson@google.com, johnniwinther@google.com

Review URL: https://codereview.chromium.org/1660703002 .
2016-02-04 12:52:39 +01: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
Bob Nystrom 67b725986b Remove some duplicate code in FunctionTypeImpl.
I noticed it when I was in there for LUB, so I figured I'd do some
spring cleaning. Changes are:

- Consolidate duplicate code in namedParameterTypes,
  normalParameterTypes, and optionalParameterTypes into a shared
  _forEachParameterType() method.
- Consolidate duplicate code in isSubtypeOf() and isMoreSpecificThan()
  into a shared _testTypeRelation() method that is parameterized over
  the specific relation.
- Also some other small-scale changes in the relation code.

R=paulberry@google.com

Review URL: https://codereview.chromium.org/1662873002 .
2016-02-03 12:51:31 -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
Paul Berry ff180530ad Fix type of JavaException.cause.
Not all thrown objects in Dart derive from `Exception`; in particular,
errors such as NoSuchMethodError derive from `Error`, which is unrelated
to `Exception`.  So in order for `JavaException` to work with both, its
`cause` field must have type `Object`.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1657413002 .
2016-02-02 14:02:43 -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
Paul Berry e9212699db Make a DirectiveElementBuilder class for use by BuildDirectiveElementsTask.
This will make it easier to re-use code between
DirectiveElementBuilder and ElementBuilder, which will be necessary as
part of fixing dartbug.com/25285.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1659523003 .
2016-02-02 09:51:00 -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
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
Paul Berry bfa85298e2 Document that LinkedExportName.name includes trailing '=' for setters.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1658773004 .
2016-02-01 12:49:29 -08:00
Konstantin Shcheglov 402ff37f16 Don't use 'info.type', always set 'element'.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1654983002 .
2016-02-01 12:41:31 -08:00