Commit Graph

8489 Commits

Author SHA1 Message Date
Paul Berry 4cd82a693e Generate useful toString() methods for summary classes.
This should make debugging easier.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1712023002 .
2016-02-19 08:33:13 -08:00
Brian Wilkerson bfacd1878c Tolerate SDKs that do not include dart:async (issue 25520)
R=danrubel@google.com

Review URL: https://codereview.chromium.org/1715563002 .
2016-02-19 07:45:54 -08:00
Brian Wilkerson 039e62d813 Improve error message (issue 25113)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1709013004 .
2016-02-19 06:15:07 -08:00
Brian Slesinsky 6715573c6e Fix cache corruption in incremental resolver
- Add an element Modifier indicating that it's a cache key.
- Don't allow the hashCode to change while it's in the cache.
- Add code in the incremental resolver to remove the cache entry
first if the hashCode will change.

Also, there appears to be a memory leak in AnalysisCache where
CacheEntry.dispose() was not usually called, so I also fixed
that.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1696193003 .
2016-02-18 18:29:42 -08:00
Brian Wilkerson 6b08743899 Add debugging support for issue 25302
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1713793002 .
2016-02-18 16:37:32 -08:00
Paul Berry 3fa8416a0c Substitute dynamic for type parameters when inferring types for JS(...)
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1711173002 .
2016-02-18 14:41:28 -08:00
Paul Berry e8848d970a Allow linked types to refer to local executables.
This allows us to summarize propagated and inferred types for a number
of corner cases where the type is a function type implied by a
closure.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1713753002 .
2016-02-18 14:17:58 -08:00
John Messerly 9bc31f7bc4 fix #25739, incorrectly expanding a generic comment multiple times
R=brianwilkerson@google.com, rnystrom@google.com

Review URL: https://codereview.chromium.org/1686173002 .
2016-02-18 14:13:39 -08:00
Konstantin Shcheglov 5db3ae73bf Always set the previous token in AstCloner.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1710163002 .
2016-02-18 13:40:32 -08:00
Konstantin Shcheglov d66aa765a2 Resynthesize enum constant field evaluation results.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1710223002 .
2016-02-18 13:27:56 -08:00
Florian Loitsch 7db06aedc4 More shared messages.
R=brianwilkerson@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1716463002 .
2016-02-18 22:13:15 +01:00
Konstantin Shcheglov 120321a4e2 Serialize and resynthesize labels.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1712583003 .
2016-02-18 12:26:16 -08:00
Brian Wilkerson 554a5e7f06 Synthetic constructors resulting from mixins should never be const (issue 25738)
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1711673003 .
2016-02-18 11:42:50 -08:00
Paul Berry 371cd6efcf Avoid duplicate effort in _getElementReferenceId
We were going to extra effort to find the compilation unit containing
[element], but it was always the immediately enclosing element.

This CL rearranges the code so that there's no duplicate effort and so
that it's clear from the flow control that the immediately enclosing
element is the compilation unit.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1710093002 .
2016-02-18 10:37:27 -08:00
Paul Berry f7d3a6f76e Store return types of variable initializers in summaries.
This required adding the ability to refer to the "bottom" type in
summaries.

R=scheglov@google.com

Review URL: https://codereview.chromium.org/1713593002 .
2016-02-18 10:19:38 -08:00
Konstantin Shcheglov 712c8d750c Fix for summarizing typedef typed parameters.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1711873002 .
2016-02-18 10:00:00 -08:00
Paul Berry d5d5dae61f Set hasImplicitReturnType for variable initializer functions.
This will make summary generation for these functions easier, since it
will allow us to re-use most of the logic for storing inferred types
when storing their return types.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1710913004 .
2016-02-18 09:07:33 -08:00
Konstantin Shcheglov 82d70054c5 Compare variable initializers as functions, skip the return type.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1714463002 .
2016-02-18 08:43:52 -08:00
Konstantin Shcheglov 72b43a3d11 Fix for making variable initializer synthetic.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1701413005 .
2016-02-18 08:27:55 -08:00
Florian Loitsch 4d26e4ec13 More shared messages.
R=brianwilkerson@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1706033002 .
2016-02-18 17:21:04 +01:00
Konstantin Shcheglov e750c71bd0 Support for 'unary-' in DeclarationResolver.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1710763002 .
2016-02-17 19:47:06 -08:00
Konstantin Shcheglov 2329db5f4a Serialize and resynthesize variable initializers.
We need them to be able to bind back elements in DeclarationResolver in
code like: var v = {'1': () => 10};

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1707073002 .
2016-02-17 13:32:54 -08:00
Paul Berry d5b4a72c5a Remove ClassElementImpl.withClauseRange.
It is not used anywhere within analyzer, and it is not part of
analyzer's public API.

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

Review URL: https://codereview.chromium.org/1709723002 .
2016-02-17 13:19:32 -08:00
Paul Berry 4eaafd3ee5 Deprecate old "isPotentiallyMutated..." API.
The getters are rewritten to return `true`.  Technically this is not a
breaking change, since all variables are "potentially mutated" in at
least a vacuous sense.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1711433002 .
2016-02-17 12:36:58 -08:00
John Messerly acc95d3195 fixes #24507, allow known functions to be treated as strict arrows
In a known function, * -> * will be top -> top.
In all other function types, it will still be bottom -> top.

R=leafp@google.com

Review URL: https://codereview.chromium.org/1700523002 .
2016-02-17 12:14:23 -08:00
Paul Berry de0a909c33 Make use of new "isPotentiallyMutated..." API in ResolverVisitor.
With this change there are no remaining uses of the old
"isPotentiallyMutated..." API anywhere in analyzer (outside of tests).

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1705173002 .
2016-02-17 11:17:25 -08:00
Florian Loitsch 830ac68d05 Share const-error messages.
R=brianwilkerson@google.com, sigmund@google.com

Review URL: https://codereview.chromium.org/1700243002 .
2016-02-17 20:10:30 +01:00
Konstantin Shcheglov 161accb68a Set FunctionTypeImpl for synthetic VariableElement.initializer elements.
I'd like to serialize initializer functions with their locals, but
as it is not, FunctionElement is incomplete and causes NPE.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1703133002 .
2016-02-17 11:00:30 -08:00
Paul Berry db588ec441 Remove unused parameter from initForIncrementalResolution
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1706943002 .
2016-02-17 10:47:01 -08:00
Paul Berry cc3aa3caa6 Check _localVariableInfo initialized in VariableResolverVisitor.
VariableResolverVisitor initializes _localVariableInfo when visiting
executable declarations, but may theoretically need to access it from
anywhere inside a function body.  This CL adds assertions to make sure
that we don't miss a case where _localVariableInfo needs to be
initialized.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1709663002 .
2016-02-17 10:44:49 -08:00
John Messerly e60ff76196 fixes #25793, make strong checker tests sane
slight code change to pass through the options flag for strong hints

R=leafp@google.com

Review URL: https://codereview.chromium.org/1700403002 .
2016-02-17 09:06:49 -08:00
Brian Wilkerson 722623d295 Discard function elements created while building elements in annotations (issue 25696)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1705773002 .
2016-02-17 08:35:57 -08:00
pq 56a9c0d9f1 LINE_INFO, TOKEN_STREAM access cleanup.
Rather than gratituitously re-scan, declare LINE_INFO and PARSED_UNIT as task inputs.

See: https://codereview.chromium.org/1702733002/diff/1/pkg/analyzer/lib/src/task/dart.dart for more context.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1702753003 .
2016-02-17 08:30:23 -08:00
Konstantin Shcheglov 6c31fe81f0 Return List<DartType> from getCurrentTypeArguments().
Otherwise when we attempt to visit it using forEach((TypeImpl t) {}),
it fails because TypeImpl and TypeParameterType are not compatible.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1702793003 .
2016-02-16 17:24:11 -08:00
Konstantin Shcheglov a012e7085e Fix the order of constructor wrappers - member of handle.
This fixes 7 failing tests with SDK summary.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1701843003 .
2016-02-16 17:17:28 -08:00
Kun Zhao 7199398092 Fix unhandle exception when access ElementAnnotationImpl.constantValue
BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1693223002 .

Patch from Kun Zhao <kunzhao77@gmail.com>.
2016-02-16 14:10:33 -08:00
Paul Berry c3d98acbeb Add data structures to AST to indicate potentially mutated variables.
These data structures provide the same functionality as
VariableElement.isPotentiallyMutatedInClosure and
VariableElement.isPotentiallyMutatedInScope, but are only accessible
from a resolved AST.  In a later CL,
VariableElement.isPotentiallyMutatedInClosure and
VariableElement.isPotentiallyMutatedInScope will be deprecated.

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

Review URL: https://codereview.chromium.org/1700263002 .
2016-02-16 14:04:25 -08:00
pq 75b1379a0f Support for line-level error suppression (#25685).
Adds filtering logic to apply source-level error suppression using a simple comment convention.  For example, suppressing an invalid assignment would look like this:

```
//# ignore: invalid_assignment
int x = '';
```

Lists are supported as well:

```
//# ignore: invalid_assignment, const_initialized_with_non_constant_value
const String y = x;
```

Conversation on final format continues (https://github.com/dart-lang/sdk/issues/25685), so this can be treated as provisional but proves out the mechanics.  Comments and concerns most welcome.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1702733002 .
2016-02-16 13:53:58 -08:00
Konstantin Shcheglov 511639d6ea Serialize and resynthesize unresolved constant instance creations.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1699243003 .
2016-02-16 13:49:18 -08:00
Konstantin Shcheglov 22b9e79090 Don't set DynamicElementImpl as staticElement for unresolved types.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1702713003 .
2016-02-16 11:58:24 -08:00
Konstantin Shcheglov 665b82d04a Serialize and resynthesize unresolved identifiers.
This is surprising, but SDK (dart2js part) has unresolved constant
expressions. So, we need to support them at least to some extent in
order to pass shared tests.

R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1700203002 .
2016-02-16 09:56:03 -08:00
Konstantin Shcheglov 8ecdb19fb2 Fix for type parameters of a local generic function in a static generic method of a generic class.
R=brianwilkerson@google.com, jmesserly@google.com
BUG=

Review URL: https://codereview.chromium.org/1692993004 .
2016-02-15 12:08:35 -08:00
Brian Wilkerson 71e7ed86c0 Move scanner out of generated and clean up imports
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1693083004 .
2016-02-14 07:48:44 -08:00
Konstantin Shcheglov a41b1fcfb6 Ignore enclosing class type parameters in resynthesizing static class members.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1695033002 .
2016-02-13 09:27:31 -08:00
Bob Nystrom e14b3c3e29 Remove redundant verbiage on inference failure errors.
As far as I can tell, the reason is always redundant with the type
error itself. If there are cases where that isn't true, I'd like to
know them.

Also, there was some seemingly dead code in there. _coerceTo() would
return an Identity coercion if fromT <: toT. Then we'd return early from
_checkAssignment().

So the success case in _inferExpression() was never hit: if you get to
the point where it's called, you know it's not a subtype already.

R=leafp@google.com

Review URL: https://codereview.chromium.org/1699463002 .
2016-02-12 16:40:46 -08:00
Konstantin Shcheglov b3ce2e1d28 Any field formal parameter has DefaultFieldFormalParameterElementImpl.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1690423002 .
2016-02-12 12:54:00 -08:00
Paul Berry 58a098e3c2 Get rid of unnecessary try/finally in resynthesize.dart
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1698443004 .
2016-02-12 12:14:04 -08:00
Paul Berry 27fa44fe6b Test and fix resynthesis of nested generic functions.
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1694763003 .
2016-02-12 11:44:57 -08:00
Konstantin Shcheglov 18808696db Add support for requesting units from resynthesizer.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1694873002 .
2016-02-12 11:42:20 -08:00
Brian Wilkerson 0616f707dd Fix parsing of generic local functions (issue 25769)
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1693963002 .
2016-02-12 11:38:02 -08:00