Commit Graph

3034 Commits

Author SHA1 Message Date
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
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
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 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
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
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
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
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
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
Konstantin Shcheglov 17118efd71 Constant instance creation dependencies also should be computed.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1533823006 .
2015-12-17 13:01:13 -08:00
Konstantin Shcheglov 83c1106ffe Compute values of elements a unit constant expressions depend on.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1539623002 .
2015-12-17 11:47:54 -08:00
Konstantin Shcheglov e5e1dc77bd Replace using '_commentBeforeFunction' with visitXyzInScope().
Otherwise it gets really ugly with using FunctionTypeAlias which does not have
a body, and getters not having a FormalParameterList, and with parameters for
function typed parameters...

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1526973005 .
2015-12-17 10:52:23 -08:00
Konstantin Shcheglov 9801d58eb7 Compute all default values of parameters.
Look at the following code.

main([p = double.INFINITY]) {}

In ConstantVerifier we validate the value of "p" and while doing this validate
the value of the ConstFieldElementImpl that corresponds to "double.INFINITY".

The problem is that we compute "double.INFINITY" in the task that requires
RESOLVED_UNIT_n, where "n" is too high. What we really need is just one value,
not all values, and of course not the resolved unit. And when we will use
summaries, we will be able to provide these values without using AST at all.

So, we need to explicitly require computation of the default value of "p",
an explicit dependency on "double.INFINITY" and its explicit computation.
Currently it still causes using ASTs, but we will change this soon.

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

Review URL: https://codereview.chromium.org/1531233002 .
2015-12-17 08:06:09 -08:00
Paul Berry 80fc29cecd Fixes to mock SDK to enable dart:core to be summarized.
This CL makes the following changes to the mock SDK used by
AnalysisContextFactory.initContextWithCore:

- Getters created by the ElementFactory have their `synthetic`
  property set correctly, and their corresponding synthetic fields
  have their `final` property set correctly.

- The following class elements all have at least one constructor:
  Function, Iterable, Iterator, Map, Null, StackTrace, Type, num,
  double, _Proxy.

This allows resynthesize_test.dart's `test_core` to pass.

Also, some minor improvements are made to resynthesize_test.dart to
allow failures to be diagnosed more easily.

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

Review URL: https://codereview.chromium.org/1532763002 .
2015-12-17 07:19:47 -08:00
Konstantin Shcheglov 9cb4fc5f1d Resolve comment references before function type aliases.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1535533002 .
2015-12-16 15:13:12 -08:00
Konstantin Shcheglov 5eb20232e3 Skip comments code blocks indented with 4 spaces.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1536483002 .
2015-12-16 14:28:30 -08:00
Konstantin Shcheglov c19e958822 Don't produce [references] in GitHub-like code blocks in comments.
Mostly for the cases when we would like to demonstrate use or
lists or maps: `a[i] == b[i]`.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1527393002 .
2015-12-16 10:32:10 -08:00
Konstantin Shcheglov ea922ef7f4 Fix for recording static elements of a prefixed comment reference.
I notied during reading idl.dart that I'd like to see highlighting and
search for type names in comment references like [PrelinkedLibrary.dependencies].

With this change we get highlighting, search and refactoring for both.
Navigation also works (*).

(*) does not work in IntelliJ - it does not parse Dart comments for reference expressions.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1531613002 .
2015-12-16 09:03:25 -08:00
Paul Berry ea7e6b29ed Introduce code to resynthesize element models from summaries.
A lot of work remains to do (see TODO comments), but the basic
infrastructure is now in place.

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

Review URL: https://codereview.chromium.org/1526243002 .
2015-12-16 08:39:56 -08:00
Brian Wilkerson 66e07636f4 Moved the tests for the element model into locations corresponding to the implementation
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1529923003 .
2015-12-16 07:49:15 -08:00
Brian Wilkerson 2a190aa11a Fix imports within the analyzer package
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1524893002 .
2015-12-14 12:25:41 -08:00
Konstantin Shcheglov 56f0adf9bf Issue 25238. Update LoclaElement(s) visible ranges during incremental resolution.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25238

Review URL: https://codereview.chromium.org/1522583005 .
2015-12-12 17:15:06 -08:00
Brian Slesinsky f0eb582d49 A class that's only used as a field type should be considered used
BUG=https://github.com/dart-lang/sdk/issues/25184
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1512833007 .
2015-12-10 13:52:41 -08:00
Konstantin Shcheglov 0f95992770 Issue 25218. The reference type of 'A' in 'A..foo' is 'Type'.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25218

Review URL: https://codereview.chromium.org/1519583002 .
2015-12-10 10:20:40 -08:00
Brian Wilkerson f0d249e269 Clean up package imports and library names
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1513643009 .
2015-12-10 08:11:56 -08:00
John Messerly 0e09465f0c fix #25183, add support to ErrorVerifier for generic methods
R=brianwilkerson@google.com, leafp@google.com

Review URL: https://codereview.chromium.org/1514683002 .
2015-12-09 15:16:00 -08:00
Leaf Petersen 9ea88b3e55 Generic method subtyping.
Fixes #25176 .

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1509263002 .
2015-12-08 14:56:47 -08:00
John Messerly c985c599ed fixes #25094, type params in static methods shouldn't always be an error
R=leafp@google.com

Review URL: https://codereview.chromium.org/1508183002 .
2015-12-08 14:08:24 -08:00
Konstantin Shcheglov 72cf3cbe91 Remove unnecessary 'noSuchMethod' declarations.
Also format these file.
I don't like how the new formatter changed the code :-(

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1507813004 .
2015-12-08 11:39:37 -08:00
Konstantin Shcheglov 1b0a5c313f Issue 24648. Report HintCode.UNNECESSARY_NO_SUCH_METHOD.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/24648

Review URL: https://codereview.chromium.org/1506903005 .
2015-12-08 10:28:38 -08:00
Paul Berry 4c28eb6f67 Merge remote-tracking branch 'origin/master' into analyzer-breaking-0.27 2015-12-08 10:16:29 -08:00
Leaf Petersen 67306ae655 Handle property accesses in generic method invocation
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1506003002 .
2015-12-07 16:01:02 -08:00
Brian Wilkerson ea3ba0e31f Remove deprecated code
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1502213002 .
2015-12-07 10:24:36 -08:00
John Messerly 095310bb36 Allow explicitly passing generic function type args
Also supports implicit dynamic correctly and ensures we have a sensible element, which fixes #25100

R=leafp@google.com

Review URL: https://codereview.chromium.org/1504483002 .
2015-12-07 09:46:38 -08:00
Paul Berry cd03a05caf Merge remote-tracking branch 'origin/master' into analyzer-breaking-0.27 2015-12-04 09:06:41 -08:00
John Messerly 6cababc94c Fixes incorrect generic function type capture
This improves how generic function types are modeled. In particular, we can now handle types like <T>T -> T, in printing, equality, and the type parameter is correctly removed when it is instantiated.

This preserves the existing lazy "substitute" operation, and makes the "instantiate" operation interact with it correctly. Given a type like:

    {T/T}<S>T -> S

we can substitute S/T to get:

    {S/T}<S>T -> S

then if we instantiate as <int> we'll get the correct:

    {S/T, int/S}T -> S, which == S -> int

This also converts typedefs over to the new system, as this seemed like the most natural thing. (However this does *not* change how the type name is evaluated, in particular given the type name "F", where "F" is a typedef `<T>T -> T`, will result in the function type `{dynamic/T}T->T` exactly as it did before. If we want to write the type `<T>T->T` we will need a different mechanism.)

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

Review URL: https://codereview.chromium.org/1488383004 .
2015-12-03 15:03:03 -08:00
Paul Berry 7d3c4743db Merge remote-tracking branch 'origin/master' into analyzer-breaking-0.27 2015-12-03 14:22:24 -08:00
Leaf Petersen 2d61ed26b7 Check for void in rules subtyping (fixes #25069)
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1497803003 .
2015-12-03 13:41:28 -08:00
Brian Wilkerson b9644af695 Remove the old task model
Review URL: https://codereview.chromium.org/1490233007 .
2015-12-03 10:14:06 -08:00
Konstantin Shcheglov dc13ac659f Fix for DeclarationResolver and invalid getters/setters.
This fixes the following exception:

Caused by The null object does not have a getter 'variable'.

NoSuchMethodError: method not found: 'variable'
Receiver: null
Arguments: []

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1492373002 .
2015-12-03 09:59:00 -08:00
Brian Wilkerson 600fc17de1 Clean-up the registration of plugins
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1487953002 .
2015-12-02 13:25:28 -08:00
Leaf Petersen daf5f6d258 Hide inference hints. Fixes #24563.
BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1498573002 .
2015-12-02 13:07:46 -08:00
Paul Berry 5528327504 Merge remote-tracking branch 'origin/master' into analyzer-breaking-0.27 2015-12-02 11:45:10 -08:00
Paul Berry c030056158 Fix erroneous restoration of task model state.
The test suite PoorMansIncrementalResolutionTest was turning on the
new task model during setup and turning it off during teardown; as a
result, any tests run after it were using the old task model.

The easy fix is to just stop trying to adjust the task model state in
this test suite, since the new task model is on by default now.

This should fix test breakages when run via pkg/analyzer/test_all.dart.

TBR=scheglov@google.com

Review URL: https://codereview.chromium.org/1497573002 .
2015-12-02 11:41:14 -08:00
Brian Wilkerson 4e3a1a468a Lexical support for configurable imports (DEP 40)
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1406253004 .
2015-12-02 11:20:07 -08:00