Commit Graph

7128 Commits

Author SHA1 Message Date
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
Paul Berry 4e0546ef44 Move NameFilter to its own file so it can be conveniently reused.
This avoids some duplication of logic in summarize_elements.dart.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1574053002 .
2016-01-11 15:47:22 -08:00
Konstantin Shcheglov 11d1147df8 Compute public namespace during resynthesizing.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1573203003 .
2016-01-11 15:05:40 -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
Paul Berry 927744e318 Handle setters properly in NameFilter.
According to the language spec (which we are trying to follow as closely
as possible in the implementation of summaries), a setter for `x` has a
name `x=`, hence a combinator like `show x` should show both the name
`x` and `x=`.

This has no immediate effect beyond the unit test for NameFilter (since
at the moment the only names which are affected by the behavior of
NameFilter are the names of classes, and they never end in `=`).  But in
a future CL I plan to use NameFilter to help build public and export
namespaces, and once that lands I will need NameFilter to handle setters
properly.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1576173002 .
2016-01-11 14:28:44 -08:00
Paul Berry a0fe3827ba Test and fix serializing a library with a missing part.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1577973003 .
2016-01-11 13:49:16 -08:00
Konstantin Shcheglov e299e4f68d Fix referencing prefixed types from parts.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1575143002 .
2016-01-11 13:44:00 -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
Konstantin Shcheglov 236237724b Fix for resynthesizing implicit top-level variables.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1577033002 .
2016-01-11 11:13:31 -08:00
Konstantin Shcheglov 65f1aa1ef0 Cache values of fields and lists in summary implementations.
This significantly improves analysis time of a trivial HTML app.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1579663002 .
2016-01-11 09:29:23 -08:00
Paul Berry 0b7c10e2b1 Create a prelinker for summaries.
The prelinker is capable of rebuilding the "Prelinked" summary
information based on the "Unlinked" information.  We will need to do
this in order to make efficient use of summaries when some files are
changed but not others, or when a pub package is upgraded but another
package that depends on it is left alone.

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

Review URL: https://codereview.chromium.org/1576743002 .
2016-01-11 07:58:21 -08:00
Konstantin Shcheglov 5e326a505c Remove BuilderContext from summary builders.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1577663002 .
2016-01-10 14:03:41 -08:00
Paul Berry 8a29a99286 Properly set UnlinkedReference.prefixReference in summaries.
This information will be necessary when a change to a file forces
summaries to be relinked.

Note that the way we determine the prefix is a bit kludgy: we look at
the export namespaces of the imported libraries and arbitrarily choose
a prefix that points to the given element.  This will give subtly
incorrect results if a name is reachable via multiple prefixes,
however this is unlikely to pose a problem in non-contrived use cases.
See the test
`fail_type_reference_to_type_visible_via_multiple_import_prefixes` for
a more detailed explanation of what might go wrong.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1574763002 .
2016-01-09 15:25:40 -08:00
Konstantin Shcheglov 68bf8244f8 Use FlatBuffers for summaries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1576663002 .
2016-01-09 10:55:00 -08:00
Konstantin Shcheglov 10adc73dab Include addBool/BoolReader into FlatBuffers.
This should simplify the code generated for summary builders/readers.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1574683002 .
2016-01-09 10:26:32 -08:00
Konstantin Shcheglov 49bc0f4b1d Remove Int64 support from FlatBuffers.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1570193004 .
2016-01-09 10:20:30 -08:00
Paul Berry 52aa46b3be Add support for Element.docRange to the summary.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1564343004 .
2016-01-09 07:05:18 -08:00
Paul Berry c0bd3091b1 Implement support for Element.documentationComment in summaries.
Support for Element.docRange will be added in a future CL.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1573633002 .
2016-01-08 14:35:26 -08:00
danrubel b852ddc41a add parser parseAsync flag
add new ASYNC_NOT_SUPPORTED error code
update ParseTask to support enableAsync
add AnalysisOptions.enableAsync flag

partially addresses https://github.com/dart-lang/sdk/issues/25373

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1570183002 .
2016-01-08 15:50:38 -05:00
Konstantin Shcheglov 26c6fc36e4 Support for writing Int32 lists.
We have one List<int> in the summaries model, so we need to be able
to write these lists in FlatBuffers.

We could probably make it more general by adding the Writer interface
and use it for writing any lists, as well as replace specialized
methods like addInt32() or addInt8() with a general addScalarField().
But this will make clients code a little bigger. Thoughts?

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1568343002 .
2016-01-08 10:40:58 -08:00
Konstantin Shcheglov 48a4c3d72e Support for Int64 and fix for the root reference.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1571593002 .
2016-01-08 10:39:31 -08:00
Paul Berry 306625d1bb Fix computation of documentationComment for class type aliases.
R=brianwilkerson@google.com, pquitslund@google.com

Review URL: https://codereview.chromium.org/1567243002 .
2016-01-08 10:37:13 -08:00
Paul Berry 55a3de53dc Set LibraryElement.entryPoint properly during summary resynthesis.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1561073007 .
2016-01-08 10:31:59 -08:00
Paul Berry daf4b9b49b Fix a few missed references to boundTypeParameters.
In 924f2f97b7, this was renamed to
`typeFormals`.

R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1563383002 .
2016-01-07 15:40:33 -08:00
Konstantin Shcheglov 5d7e5cc4bd Initial flat buffers implementation.
It supports tables and lists.

Virtual tables are not shared yet.

Construction is done forward.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1564913004 .
2016-01-07 15:21:44 -08:00
John Messerly 924f2f97b7 clean up generic methods in resolution
Introduces MethodInvocation.staticInvokeType to track the type of this invocation. This provides a natural place to store the instantiated generic function type. We then use this type when we are computing corresponding parameters or return types. As a result we do not need FunctionMember, and some of the code around generics becomes simpler/more uniform.

This approach should be a straightforward way to add support for generics in FunctionExpressionInvocation, in a follow up (see issue #25175).

Also renames "boundTypeParameters" to "typeFormals". "formals" and "actuals" is a pretty common way to describe these, I'm not sure why I didn't think of that better name originally. :)

Also removes broken ParameterMember.== that I had added in a previous CL. And the broken FunctionTypeImpl.originalFunction/instantiatedTypeArguments getters.

Finally, this fixes #23252 in the process of adding this. The return type of a "call" method was not being statically analyzed if the target was a VariableElement.

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

Review URL: https://codereview.chromium.org/1568643002 .
2016-01-07 14:51:36 -08:00
Paul Berry acc709b46b Add Element.nameOffset and LibraryElement.nameLength to summaries.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1569033002 .
2016-01-07 14:47:14 -08:00
Paul Berry f6a8f29ef0 Add uriOffset and uriEnd to the summary.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1565283002 .
2016-01-07 12:55:44 -08:00
Paul Berry 0e2393f903 Fix some corner cases of resynthesizing generic function types.
We weren't always setting FunctionTypeImpl._isInstantiated correctly,
resulting in incorrect types in some rare corner cases.  I've added a
public `isInstantiated` getter so that we can check this more
thoroughly in unit tests.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1569923002 .
2016-01-07 11:52:11 -08:00
Paul Berry 5c46fee9fa Add some corner cases for resynthesis of field formal parameters.
Field formal parameters have some strange behaviors because they are
the only thing in the language where the implicit type (if not
specified) is not necessarily `dynamic`.  So we should be careful to
test that we resynthesize them properly.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1569893002 .
2016-01-07 10:42:14 -08:00
Paul Berry 82497c1bee Fix resynthesis of variables/fields with implicit types.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1569633003 .
2016-01-07 09:32:54 -08:00
Leaf Petersen d11800e8f5 Fix type parameter element resolution for generics
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1567733002 .
2016-01-06 14:15:48 -08:00
Leaf Petersen 6d4e37cddc Add some generic method tests (currently failing).
This adds tests for some cases where explicit or inferred invocation
of generic methods is not working yet, and also for an issue around
function typed parameters.  The tests currently fail.

It also adds some missing calls to super.setUp that were preventing
solo_test from working correctly.

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1568653002 .
2016-01-06 13:43:21 -08:00
Paul Berry 9d5e7bf83d Add a count of type parameters to UnlinkedPublicName.
This will be necessary to allow summaries to be relinked.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1558353003 .
2016-01-06 11:34:21 -08:00
Konstantin Shcheglov 5debf16e88 Tests for SummarySdkAnalysisContext.
The tests use the Dart SDK summary file which we include with the tests.

Not uploading the patch for pkg/analyzer/test/src/summary/sdk_analysis_summary because the file is too large.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1567583002 .
2016-01-06 08:18:52 -08:00
Paul Berry 2a4d803b32 Test and fix resynthesized function-typed parameters referring to type parameters.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1560343002 .
2016-01-06 07:50:49 -08:00
Paul Berry 5d47028137 Eliminate constructor return types from summaries.
These can be easily inferred at the time the summary is resynthesized
into an element model.  This should make the summary size marginally
smaller, and make it easier to create summaries straight from the AST.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1565643002 .
2016-01-06 06:47:58 -08:00
Paul Berry a318062285 Test and fix resynthesized FunctionTypeImpl type args/params.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1560923002 .
2016-01-05 15:55:18 -08:00
Konstantin Shcheglov 44cb638eb9 Tests for generic functions in summaries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1566533002 .
2016-01-05 15:50:26 -08:00
John Messerly e2fa77776c fix hints from analyzer in analyzer
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1559923006 .
2016-01-05 15:19:04 -08:00
Konstantin Shcheglov 3d3b875661 Parse generic function declarations with/without type.
Currently we parse only 'void' generic function declarations.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1560663004 .
2016-01-05 14:52:41 -08:00
Paul Berry c30e64ea4b Add some forgotten test cases to summary_test.
These test cases should have been included in commit
e626abcebc.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1556123003 .
2016-01-04 15:58:03 -08:00
Paul Berry e626abcebc Encode number of type parameters in prelinked summary.
In a future CL, this should allow the element model to be
resynthesized from a summary more efficiently, since it won't be
necessary to consult the referenced elements when resynthesizing a
FunctionTypeImpl.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1555233002 .
2016-01-04 15:37:35 -08:00
John Messerly fcc84d1a03 fix #25305, DeclarationResolver.visitTypeParameter now handles generic methods
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1555213002 .
2016-01-04 15:22:48 -08:00
Konstantin Shcheglov 0eb91d0eef Test for changing method to/from getter/setter.
It does not match, so is not incrementally resolved.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1560433002 .
2016-01-04 13:29:22 -08:00
Konstantin Shcheglov a2d615e52a Replace ResultProvider with 'aboutToComputeResult'.
This way we would be able to redirect to the SDK context, or get some
results from packages. Setting ResultProvider into AnalysisDriver does
not allow us to do this.

My quick and dirty experiment with using SDK summaries is broken now,
but I'm going to start updating actual SdkAnalysisContext using
summaries, if the bundle exists in the SDK.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1555073003 .
2016-01-04 10:19:16 -08:00
Paul Berry 8991b1c58d Use List<String> for combinators in summaries.
Now that summaries can contain List<String>, there's no need to use a
list of an intermediate data structure.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1559963002 .
2016-01-04 10:11:02 -08:00
Leaf Petersen a5addef318 Fix strong mode downwards inference for async and generator functions.
Downwards inference pushes the declared return type of a function down into the body in order to infer types for the returned or yielded values.  The asynchronous and generator cases were not being fully handled correctly.

This CL changes the return context stack kept by the inference context to contain the type expected to be returned or yielded (rather than the declared return type).  At each return/yield statement, this return/yield type is used to infer types for the returned/yielded expression.  At each yield* statement, the return/yield type is wrapped into the appropriate stream/iterable type.

This CL also adds future flattening when doing downwards inference on awaited expressions to avoid inferring nested future types.

BUG=
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1555603002 .
2015-12-30 10:35:33 -08:00
Konstantin Shcheglov 8302308b71 Issue 25314. Fix for incremental resolution of a function expression body in class declaration.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25314

Review URL: https://codereview.chromium.org/1546223003 .
2015-12-27 13:16:20 -08:00
Paul Berry 8a445a3f01 Introduce code to generate UnlinkedPublicNamespace directly from an AST.
This is an initial step towards allowing the entire summary to be
generated directly from the AST rather than requiring an element model
to be built.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1544213002 .
2015-12-25 19:17:59 -08:00