Commit Graph

747 Commits

Author SHA1 Message Date
Brian Wilkerson ef1c632679 Clean up some warnings (issue 25964)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1778663006 .
2016-03-09 17:32:49 -08:00
Bob Nystrom 8defa5f77c Split resolver_test.dart into smaller files.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1782463002 .
2016-03-09 10:42:09 -08:00
Bob Nystrom 528f6c01a7 Clean up some copy/paste in a test.
Almost all of these tests had the same few steps, so I pulled that out
into a helper function and used that.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1780623002 .
2016-03-08 17:40:46 -08:00
Konstantin Shcheglov 3af20476d1 Add AnalysisContext.onResultInvalidated(descriptor).
This method will be used to remove index entries corresponding to
invalidated resolved units.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1776023002 .
2016-03-08 12:55:06 -08:00
Bob Nystrom cb7aa02116 Type check for-in statements.
This does nominal checking on the iterable expression used in a for-in
statement:

1. It must implement Iterable.
2. The type argument to Iterable must be assignable to the variable's
   type.

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

Review URL: https://codereview.chromium.org/1771153002 .
2016-03-08 11:25:49 -08:00
Brian Wilkerson d8786ac278 Change when enum constant elements are created to fix bug in re-creating ASTs from existing element models
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1771243002 .
2016-03-08 08:45:44 -08:00
pq 4528052e98 Validation of @mustCallSuper overrides.
Carried over and refined from https://codereview.chromium.org/1767843002/.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1773803002 .
2016-03-07 13:37:35 -08:00
Brian Wilkerson 508492d048 Fixes to associating existing elements with an AST
R=paulberry@google.com, scheglov@google.com

Review URL: https://codereview.chromium.org/1768713002 .
2016-03-07 10:36:36 -08:00
Kevin Moore 0ed4df8155 import cleanup
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1759483004 .
2016-03-02 17:10:01 -08:00
Leaf Petersen 7d2976c7d5 Add instantiate method on ParameterizedType and InterfaceType,
and deprecate the old substitute4 in favor of instantiate.

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

Review URL: https://codereview.chromium.org/1758913002 .
2016-03-02 15:06:38 -08:00
Leaf Petersen ce806bf307 Instantiate interface types to bounds.
Refactors some common code into TypeSystem, and makes strong mode
interface types instantiate to bounds when no type arguments are
passed.

Fixes https://github.com/dart-lang/sdk/issues/25877 .

BUG=
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1756673002 .
2016-03-02 13:18:15 -08:00
Konstantin Shcheglov 089e1ba737 Add codeOffset/codeLength properties to ElementImpl.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1753963003 .
2016-03-01 21:04:17 -08:00
John Messerly 02f888711c fix ResolutionCopier to copy staticInvokeType/propagatedInvokeType
(these will be needed for DDC generic methods)

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1754873002 .
2016-03-01 17:30:09 -08:00
John Messerly 1226c387b7 fix ResolutionCopier.visitAdjacentStrings
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1749423002 .
2016-03-01 17:28:16 -08:00
Paul Berry 5772408ed0 Clear static ElementFactory state at the start of all resolver tests.
This prevents the ElementFactory's ClassElement for `Object` (which it
stores statically) from getting accidentally shared between separate
unit tests in a single test run, which could cause state to leak
between the tests.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1752023002 .
2016-03-01 11:26:39 -08:00
Brian Slesinsky 09a7387740 Clear stale elements in an unresolved TypeName
BUG=https://github.com/dart-lang/sdk/issues/25855
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1745413002 .
2016-02-29 17:16:28 -08:00
Brian Slesinsky 44301b8001 Clear the element for imports and exports when the target doesn't exist.
This fixes a bug where the unused import hint doesn't go away after
removing the file being imported.

(Also, I suspect it fixes a memory leak.)

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1743523003 .
2016-02-29 10:06:10 -08:00
Brian Wilkerson 0185ca70fd Fix bug when @protected is not on a class member (issue 25882)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1749753002 .
2016-02-29 08:40:37 -08:00
Brian Slesinsky 41ce555c2e Update SOURCE_KIND when a missing source file appears
If the source kind isn't updated, we get a bogus error:
The imported library ... must not have a part-of directive.
This error is calculated in BuildDirectiveElementsTask.
based on SOURCE_KIND.

SOURCE_KIND is based on whether MODIFICATION_DATE is -1,
so make sure we invalidate MODIFICATION_DATE.

Also, fix an issue where _sourceChanged would have
no effect if incremental resolution isn't run, because
the content has already been updated and is therefore
equal.

Also, remove unused RelativeFileUriResolver and
clarify comments around missing Source handling.

BUG=https://github.com/dart-lang/sdk/issues/25808
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1737693004 .
2016-02-26 18:07:57 -08:00
pq 51188b6601 Prettify ignore syntax (#25685).
Prettifies ignore syntax (`//# ignore:` => `//ignore:`).

More context: https://github.com/dart-lang/sdk/issues/25685

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

Review URL: https://codereview.chromium.org/1738203002 .
2016-02-26 10:21:03 -08:00
Brian Slesinsky b9e0319763 Move errors for bad imports and exports to the directive
This is to ensure that error.source matches the source of
the ChangeNotice it appears in and the analysis server will
report the error together with other errors for the same file.

(Moving the error seems easier than figuring out how to put it
on a different Source, and it might be that the import/export
is at fault anyway.)

BUG=https://github.com/dart-lang/sdk/issues/25826
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1739553003 .
2016-02-25 11:48:26 -08:00
Konstantin Shcheglov 9aebcaa400 Don't throw exceptions for unresolved/not-existing URIs in directives.
These URIs were not resolved in the original unit and resported as
errors. So, in DeclarationResolver we also should not throw an
exception.

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

Review URL: https://codereview.chromium.org/1737203002 .
2016-02-25 10:20:43 -08:00
Brian Wilkerson c5410835a9 Improve parser recovery on missing semicolon (issue 25846)
R=jmesserly@google.com

Review URL: https://codereview.chromium.org/1736873002 .
2016-02-25 10:08:35 -08:00
pq 212a058f13 Validation of @protected property accesses.
Follow-on to https://codereview.chromium.org/1723243002/, adding support for field/getter/setters.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1730993003 .
2016-02-24 12:37:53 -08:00
pq 84f32fe5a6 Validation of @protected method invocations.
* Defines `isProtected` accessors.
* Adds a simple mechanism to our test `AnalysisContextFactory` allowing us to contribute package resolution to test cases.
* Adds `meta` awareness to `ResolverTest`.

NB: this *only* adds method invocation support.  I'll generalize to all members in a follow-up.  There's enough here though that I wanted to get some early feedback.

BUG=
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1723243002 .
2016-02-24 09:25:43 -08:00
Konstantin Shcheglov 918582490e Fix the 'Unused import' hint when using package summaries.
R=paulberry@google.com
BUG=

Review URL: https://codereview.chromium.org/1722383002 .
2016-02-24 08:16:37 -08:00
John Messerly 0c4e64c8ef fixes #25477, downward inference of generic methods
* we now push the context return type down when inferring
* we also take this into account in our initial downards inference for arguments
* adds a common AST interface for FunctionExpressionInvocation and MethodInvocation, so we can handle these more uniformly

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

Review URL: https://codereview.chromium.org/1720433002 .
2016-02-22 14:48:39 -08:00
Bob Nystrom e9a6175489 Report a static warning if a for loop condition is non-boolean.
From 17.6.1: "It is a static warning if the static type of c may not be
assigned to bool."

Strong mode catches this case, but it looks like ErrorVerifier just
missed it. Since I'm working on making strong mode lean on ErrorVerifier
for finding sideways casts like this, the discrepancy popped up.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1720083002 .
2016-02-22 12:10:52 -08:00
Konstantin Shcheglov 576e6cbfc4 Different approach to fixing file to URI mapping.
Relay on other order of library declarations in the SDK.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1715003002 .
2016-02-19 12:12:44 -08:00
Konstantin Shcheglov 1382982b60 First try to find the exact library for the given file URI.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1710393002 .
2016-02-19 10:19:55 -08:00
Konstantin Shcheglov d32b808fa8 Remove copies of ExportNamespaceBuilder and PublicNamespaceBuilder.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1717653002 .
2016-02-19 09:08:45 -08:00
Brian Wilkerson e46eaa3072 Fix node replacer to handle comments on variable declaration lists (issue 25818)
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1715723002 .
2016-02-19 08:45:25 -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
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 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
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 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
Bob Nystrom 47119ed7fe Get rid of some copy/paste in resolver_test.
R=brianwilkerson@google.com, jmesserly@google.com

Review URL: https://codereview.chromium.org/1707593002 .
2016-02-17 11:21:59 -08: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
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 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 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 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
Konstantin Shcheglov 8246f147e9 Validate cache results in incremental resolution tests.
It is OK to keep default parameter elements in the cache and so keep
all the analysis results that depend on constants in the cache.
Parameters don't use their offset in their locations, so they don't
get "lost" during incremental resolution.

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

Review URL: https://codereview.chromium.org/1693243002 .
2016-02-14 09:17:30 -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
Brian Wilkerson eca9d45bd8 Fix source used in tests
R=scheglov@google.com

Review URL: https://codereview.chromium.org/1698733002 .
2016-02-13 11:13:57 -08:00