Commit Graph

4276 Commits

Author SHA1 Message Date
Konstantin Shcheglov 72c0c77937 Fail inference when an instance field is referenced.
This is work in progress, I will clean up and document code before
committing. But I'd like to know your opinion before moving forward.

The new top-level inference rules don't allow using instance fields
to perform type inference. So, we need to make this change.

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

Review-Url: https://codereview.chromium.org/2754423002 .
2017-03-18 14:00:28 -07:00
Jennifer Messerly 3aa1be67d9 fix ? incorrectly being used in an implicit instantiation
R=leafp@google.com

Review-Url: https://codereview.chromium.org/2755283002 .
2017-03-17 19:00:25 -07:00
Jennifer Messerly f51ad4cef7 don't produce errors from inference for downward inferred type variables
R=leafp@google.com

Review-Url: https://codereview.chromium.org/2757813002 .
2017-03-17 17:06:05 -07:00
Jennifer Messerly f021a7019b fixes #27586, prefer downwards context type in generic inference
fixes #27625, Object constraints were not tracked in inference
fixes #27933, pin return type from downwards inference

We now prefer to pick the bound (lower or upper) that had some information on, and it also improves inference error messages somewhat (still a ways to go).

The way this works is we now have a type representing an unknown type: ?. We use ? when performing downward inference steps, instead of `dynamic`. This allows more accurate tracking of type constraints.

For example: given:

    var x = await Future.wait([a, b]);

Future.wait<T>'s argument type is Iterable<Future<T>>. Since we didn't know T, we previously pushed down Iterable<Future<dynamic>>. The dynamic caused loss of information. Now we push down Iterable<Future<?>>, allowing us to infer the right type there.

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

Review-Url: https://codereview.chromium.org/2456803004 .
2017-03-17 16:59:56 -07:00
Leaf Petersen e40f878abc Restore weak mode errors on empty returns in Null functions.
Fixes https://github.com/dart-lang/sdk/issues/28668 .

BUG=
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2752423003 .
2017-03-17 14:30:42 -07:00
pq 09886f491f Remove unneeded strong_mode_down_cast_composite ignores.
As `strong_mode_down_cast_composite` is now a strong-mode hint these should no longer need to be explicitly ignored.

Follow-up from: https://github.com/flutter/flutter/pull/8853

BUG=
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2755013003 .
2017-03-17 12:32:59 -07:00
Peter von der Ahé 323d5b0b7f Track async state in parser.
R=johnniwinther@google.com

Review-Url: https://codereview.chromium.org/2759623003 .
2017-03-17 14:43:07 +01:00
Paul Berry 685045d619 Start unraveling circularities between analyzer and front_end/kernel.
This CL moves many of the files from
pkg/front_end/lib/src/fasta/analyzer/ to pkg/analyzer/lib/src/fasta/.
It also moves two files from pkg/kernel/lib/analyzer/ to
pkg/analyzer/lib/src/kernel/.

This reduces the amount of circularity between analyzer and
front_end/kernel so that there are no files in front_end or kernel
which are both dependend upon by analyzer and depend upon analyzer.  I
will clean up the remaining circularities in future CLs.

There should be no functional change.

R=ahe@google.com, asgerf@google.com, kmillikin@google.com, scheglov@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2756593004 .
2017-03-17 05:56:06 -07:00
Jacob Richman a993294503 Format all analyzer packages
BUG=
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2753923003 .
2017-03-16 16:11:43 -07:00
Konstantin Shcheglov fcfe68f057 Allow AstBuilder to report parse errors.
R=ahe@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2752093002 .
2017-03-16 13:52:16 -07:00
Konstantin Shcheglov 7986cc50bd Fix also type inference for enum method invocation.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2745283007 .
2017-03-15 13:25:28 -07:00
Brian Wilkerson 40ca7292fe Improve printing of generic function types and add tests
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2752853002 .
2017-03-15 11:19:48 -07:00
Peter von der Ahé 99fa028982 Handle 'part of' declarations with URI correctly in Fasta.
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2747173002 .
2017-03-15 15:11:36 +01:00
Paul Berry c78b4d66bb Move some of analyzer's code generation utilities into front_end.
These utilities are needed for generating the code that supports
summaries; in order to move summary logic into front_end, we will need
these code generation tools in front_end as well.

Also make a minor change to summary code generation logic so that it
talks to the file system directly rather than depending on analyzer's
file system abstraction.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2742333005 .
2017-03-14 12:30:18 -07:00
Mike Fairhurst ebab20824a Formalizing the hacks letting the angular analyzer plugin run for now.
Mostly just making private methods public. But also add in some hooks
(via streams and callbacks) that allow the angular analyzer to wrap
analysis drivers in new angular drivers.

This code will likely all be reverted at some point when a much much
better plugin API is available.

BUG=
R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2742343006 .
2017-03-14 12:09:24 -07:00
Konstantin Shcheglov b9a1a29f2b Rename xFunctionBody to xBlockFunctionBody. Document related listener methods.
R=ahe@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2747853002 .
2017-03-14 10:47:31 -07:00
P.Y. Laligand 2326375fb1 Don't try to identify default analysis options for GN workspaces. (#29061) 2017-03-14 10:07:31 -07:00
Konstantin Shcheglov 63ef801665 Optionally use Fasta with the new analysis driver.
It's not ready to be enabled, but it is useful for me to enable it
temporary, see what is broken, and continue patching the AST builder.

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

Review-Url: https://codereview.chromium.org/2745163004 .
2017-03-14 08:11:18 -07:00
Vijay Menon f331ecea20 Invoke native methods directly
In DDC, if the receiver is typed and the target method simply forwards to a JS call, invoke that call directly instead of via a symbol.

This is a step toward #28307.

Paul: can you look the the analyzer / summary code change?

dart:html uses "native".  other libraries (e.g., typed_data) use "external" for more or less the same thing.  The analyzer element model doesn't provide a way to test for "native" methods, but it does for "external".  I map native to external here.  Not sure if it's better to treat them as separate (I believe native predated external).  Longer term, it may make sense to try to remove "native" in favor of "external".

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

Review-Url: https://codereview.chromium.org/2748713002 .
2017-03-13 15:11:37 -07:00
danrubel 1709021151 fix fasta summary builder
Review-Url: https://codereview.chromium.org/2742403002 .
2017-03-13 11:44:40 -04:00
danrubel ea6083f5d7 fix fasta summary builder
Review-Url: https://codereview.chromium.org/2746973002 .
2017-03-13 11:39:27 -04:00
Lasse R.H. Nielsen 5ae186153c Make Analyzer, VM and dart2js accept URI strings as part-of library identifier.
R=brianwilkerson@google.com, floitsch@google.com, hausner@google.com, johnniwinther@google.com, sigmund@google.com

Committed: https://github.com/dart-lang/sdk/commit/ef097edad6e5e4e82c3891ad2d8f9cde8fa8cfdc
Review-Url: https://codereview.chromium.org/2640853005 .
2017-03-13 08:31:40 +01:00
danrubel 090f4ca5b8 enable/disable default package contributed analysis options
This adds an option to enable or disable (enabled by default)
package contributed default analysis options.

If an analysis options file is not explicitly specified
via the "--options" option and an analysis options file
cannot be found in the project directory or any parent directory,
then look for analysis options in the following locations
if this new option is enabled:
 - package:flutter/analysis_options_user.yaml
 - package:dart.analysis_options/default.yaml

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2745653012 .
2017-03-12 13:31:45 -04:00
Konstantin Shcheglov 98c52157dc Parse factory constructors with Fasta.
R=paulberry@google.com, ahe@google.com
BUG=

Review-Url: https://codereview.chromium.org/2747583003 .
2017-03-12 09:56:45 -07:00
Brian Wilkerson 8f4a4b7288 Improve recovery in argument lists when missing a comma before a named argument (issue 29005)
R=pquitslund@google.com

Review-Url: https://codereview.chromium.org/2744043002 .
2017-03-11 08:39:40 -08:00
Konstantin Shcheglov dcf346e387 Fix for type reference for 'MyEnum.myValue.index'.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2740943005 .
2017-03-10 17:59:13 -08:00
Konstantin Shcheglov cc3946fca8 Revert "Infer types of instance methods before any other inference."
This reverts commit 8ad60b7c8b.

The change caused DDC break.

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

Review-Url: https://codereview.chromium.org/2743773004 .
2017-03-10 14:57:16 -08:00
Konstantin Shcheglov 8ad60b7c8b Infer types of instance methods before any other inference.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2741033004 .
2017-03-10 14:46:38 -08:00
Konstantin Shcheglov ee3dca40c7 Store type inference errors into EntityRef.
The errors will be associated with inference targets - top-level
variables, static class fields, instance class fields, overriding
instance method parameters with conflicting type in overridden members,
etc.

These errors will be accessible through corresponding Element(s) and
reported by LibraryAnalyzer, and so AnalysisDriver to the client. So,
we will not need to compute these errors once again in ErrorVerifier.

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

Review-Url: https://codereview.chromium.org/2736383005 .
2017-03-10 13:04:11 -08:00
Paul Berry bf83a2745b Fix errors in summary_builder.dart.
Due to a race between landing a85cdfc50f
and f8588ba47c, summary_builder wound up
with the wrong number of arguments for endLiteralString().

Not sure why this wasn't caught by buildbots.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2742913004 .
2017-03-10 12:12:49 -08:00
Brian Wilkerson 0fc6d86552 Gracefully degrade summarization when an annotation is not a valid const expression (issue 28992)
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2736373004 .
2017-03-10 09:39:39 -08:00
Paul Berry a85cdfc50f Add fasta-based summary generation code.
The code is still a work in progress, so its test is marked as failing.

Note: I believe there is code duplicatoin between the StackListener
class introduced by this CL and the StackListener class in
pkg/front_end.  Once more tests are passing, I intend to remove this
code duplication.

R=sigmund@google.com

Review-Url: https://codereview.chromium.org/2738273002 .
2017-03-09 15:38:42 -08:00
Kasper Lund b4a5a7e825 Reland "Turn the DOWN_CAST_COMPOSITE strong mode error into a hint, which will"
R=vsm@google.com
BUG=28588

Review-Url: https://codereview.chromium.org/2738223002 .
2017-03-09 06:54:59 -08:00
Kasper Lund b1ea3e01bc Revert "Turn the DOWN_CAST_COMPOSITE strong mode error into a hint, which will"
This reverts commit fa2a3a1afa.

R=vsm@google.com
BUG=

Review-Url: https://codereview.chromium.org/2739913002 .
2017-03-08 14:29:07 -08:00
Kasper Lund fa2a3a1afa Turn the DOWN_CAST_COMPOSITE strong mode error into a hint, which will
hide it unless you use an analysis options file to promote it to a warning
or an error.

R=vsm@google.com
BUG=

Review-Url: https://codereview.chromium.org/2734343002 .
2017-03-08 13:47:11 -08:00
Konstantin Shcheglov fe4378d2c8 Fix for parsing generic function types with Fasta.
R=paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2732213003 .
2017-03-07 12:03:55 -08:00
Brian Wilkerson e372b580ea Update after running the IDL generator (TBR)
Review-Url: https://codereview.chromium.org/2731403004 .
2017-03-07 10:56:36 -08:00
Brian Wilkerson 9e62d501e6 First cut at idl changes
R=paulberry@google.com

Review-Url: https://codereview.chromium.org/2719353002 .
2017-03-07 10:21:49 -08:00
Konstantin Shcheglov 571aae42b8 Issue 25733. Built-in itentifiers are not permitted as prefixes.
R=brianwilkerson@google.com
BUG= https://github.com/dart-lang/sdk/issues/25733

Review-Url: https://codereview.chromium.org/2735193002 .
2017-03-07 10:16:45 -08:00
Konstantin Shcheglov 7aa9b301e5 Fix for 'const C.named()' type inference when 'C' is resolved and has type parameters, but 'named' is unresolved.
R=brianwilkerson@google.com, paulberry@google.com
BUG=

Review-Url: https://codereview.chromium.org/2735033002 .
2017-03-07 08:49:05 -08:00
Brian Wilkerson 0fa6715bd8 More support for generic function types
Review-Url: https://codereview.chromium.org/2736643006 .
2017-03-07 08:04:01 -08:00
Claire Sarsam 1f8111e081 Fix typo in the MUST_CALL_SUPER hint message (#28971) 2017-03-07 06:32:44 -08:00
Brian Wilkerson 25989faf83 Support accessing the parameter element when there is no name
R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2725013003 .
2017-03-03 08:11:01 -08:00
Konstantin Shcheglov 99b1f617dc Mark not-optional-parameters methods of AstFactory as deprecated.
...and use non-deprecated versions in AstTestFactory.

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

Review-Url: https://codereview.chromium.org/2726943002 .
2017-03-01 11:43:55 -08:00
Konstantin Shcheglov cc7c61124b Always parse 'x.y' as a prefixed identifier.
R=brianwilkerson@google.com
BUG=

Review-Url: https://codereview.chromium.org/2722153003 .
2017-03-01 10:42:51 -08:00
Dmitry Stefantsov 9c340f9eb1 Revert last 4 commits by @lrn
Reverted commits:
* ef097edad6. ("Make Analyzer, VM and
  dart2js accept URI strings as part-of library identifier.")
* e8e1857814. ("Fix bad example of URI
  part-of to be bad, not good.")
* 58f7a92ede. ("Add changelog entry for
  allowing URI in part-of.")
* a4a7d98dce. ("Use FutureOr in
  Completer.complete.")

TBR=lrn@google.com

Review-Url: https://codereview.chromium.org/2724853002 .
2017-03-01 16:44:52 +01:00
Lasse R.H. Nielsen ef097edad6 Make Analyzer, VM and dart2js accept URI strings as part-of library identifier.
R=brianwilkerson@google.com, floitsch@google.com, hausner@google.com, johnniwinther@google.com, sigmund@google.com

Review-Url: https://codereview.chromium.org/2640853005 .
2017-03-01 12:15:11 +01:00
danrubel 0c290ae456 echo analysis options information if dartanalyzer --verbose is specified
With this change, if the dartanalyzer --verbose option is specified
then you will see additional output indicating which analysis options
file was read:

Loaded analysis options from /path/to/.analysis_options

In addition, if there are any command line flags that specify/override
an analysis option then you will see something similar to this:

Analysis options: strong = true

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2726783002 .
2017-02-28 17:49:43 -08:00
Paul Berry 79cce42e38 Add an AST factory method for fieldDeclaration with all optional named parameters.
Also add 'covariantKeyword' to the Impl constructors and named factories.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2722033002 .
2017-02-28 16:43:31 -08:00
Janice Collins 05b00a9884 Add toSource() to ElementAnnotation, ElementAnnotationImpl (issue 28631)
This is the dartdoc-required case only.

R=brianwilkerson@google.com

Review-Url: https://codereview.chromium.org/2713243003 .
2017-02-27 09:22:27 -08:00