Commit Graph

3034 Commits

Author SHA1 Message Date
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
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
Bob Nystrom b0719aa402 Remove unused or unneeded stuff from java_core.dart.
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1688113004 .
2016-02-12 11:10:48 -08:00
John Messerly d15416bdca change static method types to not have the class type parameters
R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1683343005 .
2016-02-12 09:39:28 -08:00
Konstantin Shcheglov ea249124fe Mark FunctionExpression elements as used in DeclarationResolver.
R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1692533004 .
2016-02-12 07:05:49 -08:00
Bob Nystrom 1fb9cebd6e Get rid of redundant MockSdk.
The two in src/mock_sdk.dart and src/context/mock_sdk.dart were almost
identical. The former was only used in one place, so I made the latter
support that case.

Also cleaned up a few other minor things I noticed along the way.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1691603002 .
2016-02-11 15:20:04 -08:00
Konstantin Shcheglov 9184f3862e Issue 25385. Set documentation comment for enum constants.
R=brianwilkerson@google.com, paulberry@google.com
BUG= https://github.com/dart-lang/sdk/issues/25385

Review URL: https://codereview.chromium.org/1689303002 .
2016-02-11 14:37:23 -08:00
Konstantin Shcheglov c4602b0c8b Don't use Set when collecting constant targets in a unit.
This forces location / hashCode computation and caching, and the unit
is not linked to its library, so the cached values are not valid.

R=brianwilkerson@google.com
BUG=

Review URL: https://codereview.chromium.org/1691943002 .
2016-02-11 12:35:33 -08:00
Bob Nystrom e19c6dd79d Consolidate the code that replaces a TypeParameter with its bound.
In the process, I fixed a bug where one version of this same lump of
code wasn't correct anymore now that you can have arbitrarily long
chains of type parameters.

DartType isn't maybe the ideal place for resolveToBound(). I wanted it
somewhere that:

1. Would be obvious enough that someone coming along later would
   discover it instead of reinventing it again.
2. Had access to the various data it needs.
3. Wouldn't need a "is TypeParameterType" guard at every callsite
   before it could be used.

I could put it on TypeProvider instead, since it needs access to Object,
but that felt arbitrary.

It could be a top level function, but then I don't think it would be
very discoverable.

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

Review URL: https://codereview.chromium.org/1686893002 .
2016-02-11 11:27:01 -08:00
John Messerly 6bf029a5c7 fixes #25641, error message when type arguments do not match
R=rnystrom@google.com

Review URL: https://codereview.chromium.org/1683203002 .
2016-02-10 14:46:31 -08:00
Konstantin Shcheglov 135be23107 Issue dev_compiler@443. Clone beginToken.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/dev_compiler/issues/443

Review URL: https://codereview.chromium.org/1686653003 .
2016-02-09 19:24:14 -08:00
Bob Nystrom 3f3b242f39 Probably don't need an unused re-implementation of addAll(). :)
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1674963002 .
2016-02-08 15:12:10 -08:00
William Hesse b201036951 Remove import of AnalysisException from wrong library.
The class comes from generated/java_engine.dart, not generated/engine.dart

BUG=
R=paulberry@google.com

Review URL: https://codereview.chromium.org/1680703002 .
2016-02-08 17:27:24 +01:00
Paul Berry 079e8a1d62 Fix confusion between parameters vs arguments in parser.
There are two changes:

1. Modify `_isPeekGenericTypeParametersAndOpenParen` to call
`_skipTypeParameterList` instead of `_skipTypeArgumentList`.  This
fixes parsing of generic function declarations like `f<@a T>() {}`,
which previously couldn't be parsed because `<@a T>` isn't a valid
type argument list.

2. Rename `_isLikelyParameterList` to `_isLikelyArgumentList` to
reflect how it is actually used (and what it actually does).  This is
no user-visible effect.

R=brianwilkerson@google.com

Review URL: https://codereview.chromium.org/1674043002 .
2016-02-07 10:42:32 -08:00