Commit Graph

2147 Commits

Author SHA1 Message Date
Paul Berry 5268afc378 Add more type inference uses cases to AST-based summaries.
With this CL, we support type inference of fields and property
accessors (when generics are not involved) based on inheritance.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1853433006 .
2016-04-01 09:44:02 -07:00
Brian Wilkerson 6dae827b70 More strong mode fixes for analyzer
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1842363004 .
2016-04-01 09:35:22 -07:00
Konstantin Shcheglov 8dcba124cf Increment version before publishing a new version of analyzer.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1847853005 .
2016-04-01 09:08:03 -07:00
Paul Berry a829226945 Add support for method parameter type inference to AST summaries.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1849843003 .
2016-04-01 08:59:00 -07:00
Paul Berry 2706796239 Begin implementing type inference for AST summaries.
As much as possible, we re-use the logic of InstanceMemberInferrer.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1845403003 .
2016-03-31 15:12:51 -07:00
Konstantin Shcheglov fd4e357413 Issue 26147. Don't attempt to set the type of the parameter for setters without parameters.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/26147

Review URL: https://codereview.chromium.org/1850623005 .
2016-03-31 13:46:41 -07:00
Konstantin Shcheglov 054be34e6c Issue 26148. Don't use a current token if it does not match - create a new synthetic.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/26148

Review URL: https://codereview.chromium.org/1851623002 .
2016-03-31 13:40:17 -07:00
Brian Wilkerson e531f01e73 Fix more strong mode errors in analyzer
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1847633002 .
2016-03-31 13:30:04 -07:00
Konstantin Shcheglov 498c77ef51 Issue dartdoc#1124. Get used elements from directive comments.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/dartdoc/issues/1124

Review URL: https://codereview.chromium.org/1850813002 .
2016-03-31 12:42:51 -07:00
Konstantin Shcheglov 05df65f7db Issue 26146. Get next token after '{' or '}' while skipping interpolations.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/26146

Review URL: https://codereview.chromium.org/1847093002 .
2016-03-31 10:40:43 -07:00
Konstantin Shcheglov 868a5c582c Publish 0.27.3-alpha.6 with the infinite recursion fix.
R=paulberry@google.com, brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1837383003 .
2016-03-30 13:06:41 -07:00
Paul Berry c8fb5078d0 Use standard TypeImpl classes during linking.
The `...TypeForLink` classes weren't contributing any useful
functionality, and removing them will make it easier to re-use code from
the rest of the analyzer.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1842183002 .
2016-03-30 13:01:59 -07:00
Konstantin Shcheglov a202419882 Fix InSummarySourceTest on Windows.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1848583002 .
2016-03-30 13:00:07 -07:00
Konstantin Shcheglov 01c7e120dd Fix for infinite resursion while finding a concrete method.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1846703002 .
2016-03-30 12:35:43 -07:00
Paul Berry fa7f49546b Make a test of summarizing ASTs in strong mode.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1840263002 .
2016-03-30 10:34:30 -07:00
Leaf Petersen ce861a7c9c Closures shouldn't have fuzzy arrow type.
Fixes https://github.com/dart-lang/sdk/issues/26118 .

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1838383002 .
2016-03-29 22:48:14 -07:00
Paul Berry a88e4f2cf3 Mark a test in summarize_ast_test.dart as newly passing.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1843013002 .
2016-03-29 16:42:56 -07:00
Leaf Petersen 4e5bc83285 Better strong mode least upper bound for interface types. Adds some
checks to handle common cases of least upper-bound computations
on type parameters and interface types in a more reasonable way
than the spec lub.

BUG=
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1843453002 .
2016-03-29 16:36:38 -07:00
Paul Berry f9fea19384 Clean up trivial cycle detection logic.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1839863005 .
2016-03-29 16:31:44 -07:00
Konstantin Shcheglov 0361013c12 Issue 26106. Don't attempt to incrementally resolve sources without contents.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/26106

Review URL: https://codereview.chromium.org/1844683002 .
2016-03-29 16:21:19 -07:00
Paul Berry cfbe56db31 When building summaries from ASTs, handle circularities involving .length.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1841283002 .
2016-03-29 16:19:55 -07:00
Paul Berry fd09ad2813 Fix summary detection of cycles via redirect/super arguments.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1841853002 .
2016-03-29 16:08:38 -07:00
Konstantin Shcheglov 2d3a202987 Prepare for publishing analyzer 0.27.3-alpha.5
R=jmesserly@google.com, paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1843703003 .
2016-03-29 12:15:02 -07:00
Paul Berry b116b97a0b Handle redirected constructors when generating summaries from ASTs.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1840843003 .
2016-03-28 19:50:15 -07:00
Konstantin Shcheglov ce0fbc63cd Serialize references to type parameters in final fields.
When we generate SDK summary using AST (just for testing) we find code
like this:

class _SimpleCallbackSink<T> extends ChunkedConversionSink<T> {
  final _ChunkedConversionCallback<List<T>> _callback;
  final List<T> _accumulated = <T>[];

  _SimpleCallbackSink(this._callback);

  void add(T chunk) { _accumulated.add(chunk); }
  void close() { _callback(_accumulated); }
}

It is not a valid constant, but we don't know this on AST level.
We could probably detect this, but I guess we would need to serialize
a wider set of expressions for type propagatation / inference anyway,
so it is better to serialize than to fail in this case.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1841603003 .
2016-03-28 19:45:45 -07:00
Konstantin Shcheglov ffd62c6a18 Resynthesize any type reference in constant expressions.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1837063002 .
2016-03-28 18:59:06 -07:00
Paul Berry 8835741088 Fix a corner case of constant evaluation cycle detection.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1841523003 .
2016-03-28 18:50:14 -07:00
Paul Berry af334712d0 Fix up generated code after sorting analyzer source files.
TBR=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1842623002 .
2016-03-28 18:49:07 -07:00
Brian Wilkerson deae702994 Format everything in analyzer
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1842563003 .
2016-03-28 18:16:43 -07:00
Brian Wilkerson 513433d514 Sort analyzer sources
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1843473002 .
2016-03-28 17:41:52 -07:00
Konstantin Shcheglov d8af43e5e2 Don't serialize Label in NamedExpression as a label declaration.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1842533002 .
2016-03-28 14:53:29 -07:00
Brian Slesinsky 2a41dc6734 Increase AST cache size to improve performance for large projects
In the test I tried using dartanalyzer, it reduces the
execution time from 170 seconds to 102 seconds.

BUG=
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1841433003 .
2016-03-28 13:53:38 -07:00
Konstantin Shcheglov 7f145a0ad9 Fixes for AST summary generation when variables are missing.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1839643003 .
2016-03-28 13:51:27 -07:00
Konstantin Shcheglov daab52a191 Add the '--build-summary-only-ast' flag for generating summaries using only ASTs.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1838883002 .
2016-03-28 13:36:12 -07:00
Brian Wilkerson ee105910be Improve highlighting for strong mode error
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1834213002 .
2016-03-28 13:35:43 -07:00
Paul Berry 23dfde7e3e Fix a corner case of building summaries from ASTs.
Make sure that we can't crash the summary generation code by erroneously
using a type parameter as the supertype of a class.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1836033002 .
2016-03-28 13:10:53 -07:00
Paul Berry 03c401f3fd More fixes to summary linking.
This CL makes the following fixes:

- Handles the case where a constant makes an explicit reference to a
  type.

- Handles references to top level names defined in imported libraries.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1839663003 .
2016-03-28 12:22:30 -07:00
Konstantin Shcheglov 3899031ff5 When summarize AST, include local variables in loops and try-catch.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1842433002 .
2016-03-28 12:00:01 -07:00
Paul Berry ed4725071e Fix semantics of CompilationUnitElementForLink.types.
Enums should not have been included.  They are exposed via
CompilationUnitElementForLink.enums.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1837813002 .
2016-03-28 11:58:39 -07:00
Paul Berry 3a69300644 Fix AST summarization when there are explicit calls to super constructors.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1835313002 .
2016-03-28 10:51:44 -07:00
Paul Berry fbeff9c904 Add more features to the summary linker.
We now detect constant cycles involving:

- Named constructors.

- Generic classes.  (Note: we don't track the type arguments of
  generic classes yet, because that's unnecessary for detecting
  constant constructor cycles).

- References to top level constant variables and constant fields.

- Final fields in constant classes.

- Implicit calls to "super".

Also, we properly handle constants that refer to fields of an enum
class.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1832393002 .
2016-03-28 10:39:37 -07:00
Paul Berry ca47517be8 Fix summary handling of enum values.
This CL fixes:

- Computation of the public namespace when there are enums (previously
  we weren't including enum values in the public namespace).

- Prelinking of references to enum values from constants.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1841433002 .
2016-03-28 09:55:17 -07:00
Paul Berry 6455b3e591 First steps toward generating fully linked summaries from ASTs.
This CL adds a summary "linker", which wil be capable of taking the
output of the prelinker and adding the information that potentially
requires traversing transitive dependencies (propagated and inferred
types, and constant constructor cycles).  When this is finished we
should be able to generate summaries straight from ASTs without
building a full element model in the interim.

The basic technique is to build a miniature element model, on demand,
which is discarded when linking is finished.  Since the miniature
element model is only for a single purpose, it can be much more
compact than the full element model.  Since it is thrown away after
linking, it can avoid the expensive dependency tracking that would be
necessary in order to keep the data structure up to date when there
are code changes.

So far I've built the basic infrastructure and started implementing
constant constructor cycle detection.  Areas that still need to be
filled out are indicated by TODO comments.

Since the linker only has access to the UnlinkedUnit objects (not the
ASTs), it will be necessary to add a small amount of information to to
the UnlinkedUnits to record the information needed by type inference.
I'm hoping that it will be possible to adapt the existing
UnlinkedConst data structure for this purpose.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1828543009 .
2016-03-28 09:02:21 -07:00
Konstantin Shcheglov f6e4f4c053 Fix for labels and the 'inDeclarationContext' flag.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1839443002 .
2016-03-28 08:44:48 -07:00
Konstantin Shcheglov 3302edbb06 Fix for 'hasNoSupertype' for Object when summarize AST.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1839633002 .
2016-03-28 08:41:57 -07:00
Konstantin Shcheglov f175ef0116 Fix for resolveRelativeUri() when the containedUri is absolute.
R=paulberry@google.com, brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1835643002 .
2016-03-25 12:53:21 -07:00
Konstantin Shcheglov ba25813b44 Fixes for using _DeferredClassElement and SDK summary.
R=paulberry@google.com, brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1837523002 .
2016-03-25 10:53:49 -07:00
Bob Nystrom 31aa8e26df Distinguish SimpleIdentifier uses and declarations at parse time.
Instead of a very slow .inDeclarationContext() method which determines
whether a given identifier is in a use position or not, we just create
a different subclass at parse time that encodes that fact directly.

Also, remove an unnecessary _validateElement() method.

On my Mac laptop, this takes benchmark/errors_in_all_libraries.dart

From: 0:00:05.673849
To:   0:00:05.193563 (91.53%)

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1833573006 .
2016-03-25 10:38:22 -07:00
Paul Berry 9e52ab17e0 Consolidate duplicate code for resloving URIs.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1831133005 .
2016-03-25 10:37:36 -07:00
Konstantin Shcheglov 0dfa93772e Use shared MockSdk instances in resynthesize tests.
This restores tests performance mostly to where it was before, modulo
additional time for a new UnlinkedSummarizeAstTest set of tests.

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

Review URL: https://codereview.chromium.org/1838453002 .
2016-03-25 10:22:25 -07:00