Commit Graph

5559 Commits

Author SHA1 Message Date
Konstantin Shcheglov af110a7aa4 Change resolution of assignment to PropertyAccess.
Change-Id: Ie9de1166eb0dfd179d539f1b10c54084caf643d6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162248
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-09-11 15:50:20 +00:00
Stephen Adams 8d68480746 [dart2js] Fix global type analysis
https://github.com/dart-lang/sdk/issues/43366

Fixed: 43366
Change-Id: Iac8247c31fa268186c8f2e3f52e0be1cac062598
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162247
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
2020-09-11 04:07:41 +00:00
Tess Strickland 3d77741666 [vm/compiler] Unify name checking in dynamic closure call dispatchers.
Instead of possibly looping over the closure function parameter names
array multiple times, just do it once. Check each entry against the
provided argument names. If none match, check the required bit (if in
null-safe mode). Also keep a count of matched names to check that all
provided names matched after the iteration.

Now that optional name checking is part of the fragment built by
BuildClosureCallArgumentsValidCheck, that method builds checks for
exactly the same things as its namesake in Function.

Also refactor the variables used by the checker into read/write ones
that need to be allocated in the parsed function and read-only ones
that can just be temporaries since no Phi nodes are needed.

Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-linux-debug-x64-try,vm-kernel-precomp-linux-release-simarm_x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try
Bug: https://github.com/dart-lang/sdk/issues/40813
Change-Id: I3cb421dd538629d7f5499f3bbf0653d34b850dce
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160725
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
Reviewed-by: Daco Harkes <dacoharkes@google.com>
2020-09-10 07:12:14 +00:00
Johnni Winther 0e93845ba1 Make update_static_error_tests work on Windows (again)
+ update some test expectations

Change-Id: I63ca86309ea3352a88686f5e3f416311ee7bc03c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/162185
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2020-09-10 06:21:13 +00:00
Jens Johansen 0c90775fd6 [CFE] Better error messages for class initialization errors
Change-Id: Ic7c489b0bfffd05cdd71dc254db042956fd25c3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161944
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-09-09 11:37:47 +00:00
jlcontreras 42c4c3c1bd [cfe] Add Jenkins SMI hashcode combiner
Change-Id: I542369fc2d8443bb0094fdedc11596fdc2f20e2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159084
Commit-Queue: Javier López-Contreras <jlcontreras@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2020-09-07 12:36:13 +00:00
Clement Skau 90652bc314 [VM] Fixes nested sync* w. diff. types.
Makes the synthetic sync* iterator dynamic to allow the internal,
synthetic sync* code to handle nested iterators of differing types.

Bug: https://github.com/dart-lang/sdk/issues/42234
Change-Id: I309885b27555142cd7f8ab13a5637b35545f1d44
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160071
Reviewed-by: Martin Kustermann <kustermann@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-09-03 11:48:44 +00:00
Konstantin Shcheglov a51197194f Fix test for abstract field, not impelemnetd by the mixin application.
Change-Id: I1d12a70a82a859d57516948672ed6a931904ae7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161626
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-03 01:15:23 +00:00
Nicholas Shahan a7fbb3ffe3 Add regression test for issue #43281
Change-Id: Iae1c81f60ccc36708601d73d426f4fbc6f119084
Issue: https://github.com/dart-lang/sdk/issues/43281
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161627
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-09-03 00:38:52 +00:00
Konstantin Shcheglov 01024dfa5a Issue 43200. Report ASSIGNMENT_TO_FINAL when 'final late' has an initializer.
Bug: https://github.com/dart-lang/sdk/issues/43200
Change-Id: Ib79b4e8246f8f67661212c3d107de961d72132b4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161471
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-02 15:38:22 +00:00
Johnni Winther 7130dd4d3d [cfe] Report error on non-void setter return type
This CL also adds fileUri/charOffset to all TypeBuilder's and renames
Void/FutureOr/Never/Dynamic/BuiltInTypeBuilder to *TypeDeclarationBuilder
so match their relation to TypeBuilder/TypeDeclarationBuilder.

Closes #42962

Change-Id: Iee5102134574d24f748103282a37bb9a85a0ac2d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161165
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2020-09-02 12:43:12 +00:00
Konstantin Shcheglov d9b874c4b5 Resolve AssignmentExpression with SimpleIdentifier directly.
Change-Id: I81cc3d6b1cf31d840727300c0a22e8acfa5bf17c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161261
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-09-01 22:15:41 +00:00
Ryan Macnak c1bb9a520c [vm] Don't write LibraryPrefix::importer_ in AOT snapshots.
This field won't be used at runtime and is not accounted for during tree-shaking.

Bug: https://github.com/dart-lang/sdk/issues/41974
Bug: https://github.com/dart-lang/sdk/issues/43245
Change-Id: Ie5a669608e896aa8cee74a3a4249ba99ec6f980a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/161220
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Ryan Macnak <rmacnak@google.com>
2020-09-01 16:49:49 +00:00
Konstantin Shcheglov 5f3298eeac Set readElement/Type and writeElement/Type for PostfixExpression.
R=brianwilkerson@google.com

Change-Id: I449503648192e4b2d1d65304d65a12f74d589bcc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160785
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-28 14:45:08 +00:00
Jacob MacDonald e7b3737b84 add opt in/out tests which are pinned to the experiment release version for nnbd
These tests don't have a lot of value right now - but will have more value as of the 2.11 release.

I am also going to manually validate that they work if I bump the sdk version to 2.11.

Bug:https://github.com/dart-lang/sdk/issues/43034
Change-Id: I7a86f5698ad4c8a0d17d4ae68ecb2143ef7b378f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160704
Auto-Submit: Jake Macdonald <jakemac@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
Commit-Queue: Jake Macdonald <jakemac@google.com>
2020-08-28 02:39:07 +00:00
Konstantin Shcheglov 893481591a Store readElement/Type and writeElement/Type in AssignmentExpression.
Change-Id: Ibe0eea6126c7e85cdfefa09652228b5a89b522cd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160444
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-27 20:22:14 +00:00
Konstantin Shcheglov a717fd41e3 Issue 42379. Allow null-shorting only for increment operators in prefix expressions.
Bug: https://github.com/dart-lang/sdk/issues/42379
Change-Id: I366702f144a4350bed6b83c5c0936359aeeae2c1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159960
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-25 23:05:03 +00:00
Konstantin Shcheglov 5c9d9f8616 Don't report INVALID_NULL_AWARE_OPERATOR where INVALID_OPERATOR_QUESTIONMARK_PERIOD_FOR_SUPER is already reported.
Change-Id: I016821804d062f8c07103d4107b88222b1e2a92e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159966
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-08-25 15:16:00 +00:00
Clement Skau 4db081545e Revert "[VM] Fixes yield* exception handling in sync*."
This reverts commit 358aee331b.

Reason for revert: Appears to break service/async_generator_breakpoint_test

Original change's description:
> [VM] Fixes yield* exception handling in sync*.
> 
> This adds a mechanism similar to that used in async functions where
> exceptions are caught in the synthetic code and passed into the
> generated body to be rethrow'n.
> This ensures the exception is throw'n from the same place as the
> original yield*, as per the spec.
> 
> Bug: https://github.com/dart-lang/sdk/issues/42466
> Change-Id: I553dd89141985f6f30751913a1c8a62b1229af04
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158543
> Commit-Queue: Clement Skau <cskau@google.com>
> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>

TBR=vegorov@google.com,cskau@google.com

Change-Id: I9df83543d41d4260e91e4a7fb8df7c2762b92429
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/dart-lang/sdk/issues/42466
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/160101
Reviewed-by: Clement Skau <cskau@google.com>
Commit-Queue: Clement Skau <cskau@google.com>
2020-08-25 14:08:42 +00:00
Clement Skau 358aee331b [VM] Fixes yield* exception handling in sync*.
This adds a mechanism similar to that used in async functions where
exceptions are caught in the synthetic code and passed into the
generated body to be rethrow'n.
This ensures the exception is throw'n from the same place as the
original yield*, as per the spec.

Bug: https://github.com/dart-lang/sdk/issues/42466
Change-Id: I553dd89141985f6f30751913a1c8a62b1229af04
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/158543
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
2020-08-25 12:40:49 +00:00
Robert Nystrom df9200ec27 Test the runtime checks in mixed-mode programs for unreachable code.
Change-Id: I83a5dd939fb9e7165e72d4e254aa87d17d38eee4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159200
Reviewed-by: Leaf Petersen <leafp@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2020-08-24 22:31:07 +00:00
Lasse Reichstein Holst Nielsen ce494e7910 Add test for inference solving T? = dynamic.
See https://github.com/dart-lang/language/issues/1035

Change-Id: Ieb258a020d8212f5488cc3d73978b8132223353d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151760
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Leaf Petersen <leafp@google.com>
2020-08-24 16:09:33 +00:00
Konstantin Shcheglov afd6344e99 Add write tests, fix write_error_test.dart
Bug: https://github.com/dart-lang/sdk/issues/43100
Change-Id: Ib01192e73905ae1c431491e89e269fd25c6cd9cf
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159680
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-22 00:24:31 +00:00
Konstantin Shcheglov 25edea3d8d Issue 43100. Verify local variable reads for null safety.
Bug: https://github.com/dart-lang/sdk/issues/43100
Change-Id: Ia8ece4de32f65d7912e534ce61936a45f2c768c0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159382
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-08-20 15:50:50 +00:00
Paul Berry 4280e0a819 Fix crash when a null shorting expression is null checked.
Postfix increments and decrements are null-shorting expressions
(e.g. `x?.y++.isEven` only calls `isEven` if `x` was non-null), but it
is still being decided whether postfix `!` should be null shorting
(i.e. whether `x?.y!` should fail if `x` is null).  See
https://github.com/dart-lang/language/issues/1163.

Previously, the analyzer was inconsistent about whether it considered
`!` to participate in null shorting; as a result, when analyzing an
expression like `x?.y!`, the analyzer would fail to call
`FlowAnalysis.nullAwareAccess_end`, resulting in corrupted flow
analysis state, which could lead to a crash.

This change makes the analyzer treat `!` as *not* participating in
null shorting, which is consistent with what is currently written in
the spec and implemented in the CFE.

Fixes #43093.

Change-Id: Ie69c5c29f226fe1a0282d0e7a1e079778dc700c3
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/159147
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-19 19:35:57 +00:00
Leaf Petersen 9cae6aa746 Add definite assignment tests.
New tests for the definite assignment related changes specified in
https://github.com/dart-lang/language/pull/1091 .

Change-Id: I119e36c1bddca97f7021c9015b0f2eee5cb80969
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157881
Reviewed-by: Erik Ernst <eernst@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-08-19 03:27:31 +00:00
Robert Nystrom 5be77279cd Migrate package:dart_internal to null safety.
This also highlighted a couple of mistakes in the patch files for

dart:_internal and the test.
Change-Id: I60b4e7d5673d64f85a95108c9e03f9328249b9d0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/153021
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Auto-Submit: Bob Nystrom <rnystrom@google.com>
2020-08-17 23:06:35 +00:00
Tess Strickland 787446213c [vm/compiler] Move argument shape (not type) checks out of closures.
This CL performs the following checks in the invoke field dispatcher for
dynamic closure calls when lazy dispatchers are enabled:

* The provided function type arguments vector (if any) has the correct
  length.

* No function type arguments should be provided if the closure has
  delayed type arguments.

* All required arguments (positional in all modes, named in appropriate
  null safety modes) have been provided by the caller.

* If there are optional positional arguments, an appropriate number
  has been provided.

* If there are optional named arguments, their names are valid.

Since the runtime already handles checking the argument shapes when lazy
dispatchers are disabled, these checks are now completely removed from
closure bodies in all cases. Thus, the only remaining checks in closure
bodies are the type checks performed by AssertSubtype and
AssertAssignable when lazy dispatchers are enabled.

Changes in the Flutter Gallery:

* ARM7, release: -3.61% instructions, -2.19% total
* ARM7, sizeopt: -3.62% instructions, -2.55% total
* ARM8, release: -3.66% instructions, -1.98% total
* ARM8, sizeopt: -3.65% instructions, -2.37% total

Most of these changes are already exercised by existing tests such as
(but not limited to):

* corelib{,_2}/dynamic_nosuchmethod_test
* language{,_2}/call/call_test
* language{,_2}/closure/tearoff_dynamic_test
* language{,_2}/generic/function_bounds_test
* language{,_2}/parameter/named_with_conversions_test
* language{,_2}/vm/no_such_args_error_message_vm_test

I've added one test to specifically check the interaction between
dynamic calls and required named parameters. There is some coverage in
other NNBD tests, but those are not directly focused on testing this
specifically.

Other changes:

* Adds initial cached ranges for certain BinarySmiOp and ShiftIntegerOp
  instructions when the RHS is a constant, to avoid false negatives for
  deoptimization and throw checks prior to range analysis.

* Adds new slots for various Function fields.

* Adds the ability to define unboxed native slots, which are always
  unboxed after retrieval even in unoptimized code. In the first
  iteration, the backend only handles loads from Uint32 unboxed native
  slots. Part of https://github.com/dart-lang/sdk/issues/42793.

* Removed the special handling for loading from non-nullable int fields
  in AOT compilation. Instead, their treatment is unified with the
  treatment of the new unboxed native fields, since the source field is
  always unboxed and the result of the load is also always unboxed, as
  code involving them is always optimized.

Bug: https://github.com/dart-lang/sdk/issues/40813
Change-Id: Ia02aa3e872c1fefd906fd67b55021ea1797556e4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155604
Commit-Queue: Tess Strickland <sstrickl@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-17 08:58:08 +00:00
Paul Berry e403e6ae77 Flow analysis: rework handling of equality tests.
The new logic classifies the LHS and RHS of the equality check as
either null, non-nullable, or potentially nullable, and then either
promotes, treats the expression as equivalent to a boolean, or does
nothing, as appropriate.

This means, for example, that a comparison between a non-nullable
value and `null` is now known to evaluate to `true` for reachability
analysis.

Note: as part of this change, it was tempting to trigger promotion
whenever a varialbe is equality compared to an expression of type
`Null`, but this would be unsound (consider `(int? x) => x == (x =
null) ? true : x.isEven`).  So we still only promote when the variable
is compared to a literal `null`.

Fixes #41985.

There's a corresponding spec change out for review:
https://github.com/dart-lang/language/pull/1134

Change-Id: Id7f1d4eaa3b0fa57124445bb8352eef32c304feb
Bug: https://github.com/dart-lang/sdk/issues/41985
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155926
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2020-08-14 12:16:36 +00:00
jlcontreras d16bc3a3dd Add sample language tests for valueClass feature
Add experimental_flag protection

Change-Id: I0dc83fd544beb58dce5631a2a80d4d9321e866ca
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155607
Commit-Queue: Javier López-Contreras <jlcontreras@google.com>
Reviewed-by: Erik Ernst <eernst@google.com>
2020-08-12 16:02:14 +00:00
Paul Berry 490a4b65e2 External field support: suppress "uninitialized non-nullable field" errors.
External fields whose type is non-nullable don't need to be
initialized (in fact they can't be initialized), so we shouldn't
report "uninitialized field" errors for them.

This CL also adds some basic tests of the functionality of external
fields, making sure that the getters and setters they introduce are
properly resolved and that their types are properly respected by
inheritance checks.

Change-Id: I9b08727ab0d45d24801af3721e332c7ec21d08bc
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157840
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-11 19:32:12 +00:00
Brian Wilkerson e224540b1c Unify four diagnostic codes for the purpose of documentation
I would have prefered to have renamed them all to undefined_super_member,
but that would have broken existing links. Some day we should add the
support necessary to allow for forwarding so that we can rename codes.

Change-Id: I81e416407e3464b5b60a4dbbfe60a375eb47bb84
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157921
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-08-11 01:07:44 +00:00
Paul Berry d4e4abdef6 External field support: add a notion of external fields to the AST and element model.
In follow-up CLs I will update error reporting logic.

Change-Id: Id07b861aa117b93e0c869ad0b52c048085706ee6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157801
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2020-08-10 21:54:54 +00:00
Brian Wilkerson 276f10aaf6 Unify const_field_initializer_not_assignable with field_initializer_not_assignable for documentation purposes
Change-Id: I7b008febe4210d08768b81c59bf0ee6b2663fafd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157900
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
2020-08-10 19:48:03 +00:00
Regis Crelier f8d1d003c9 Reland "[VM/runtime] Fix computation of the hash of recursive types."
This is a reland of a528b19d2c

Updating the hash of the empty type argument vector in write-protected memory caused a crash in precomp mode.
The fix is to correctly initialize the hash so it does not need an update.

Original change's description:
> [VM/runtime] Fix computation of the hash of recursive types.
>
> When computing the hash of a type, only include the hashes of the type arguments corresponding to the type parameters of the type's class and not of the whole type argument vector, otherwise, the variable location of TypeRefs in the base class type arguments may result in different hashes.
>
> Add a regression test (this test was not failing in all configurations, since the issue becomes visible depending on the order in which types are loaded and finalized).
>
> This fixes issue https://github.com/dart-lang/sdk/issues/42954
>
> Small improvement: pick hash value 1 for a vector of dynamic types, so it can be cached and not recomputed repeatedly, which was the case with value 0.
>
> Change-Id: I3468952cbf61944a82cf8e00efbf4952bd831fbe
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157563
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

Change-Id: I538b4538c69472e09b7bd745c6bd41023e1f154f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157781
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-07 21:13:35 +00:00
Erik Ernst becf615d11 Add test for missing initializer on final instance variable
Add a test where a class that has no generative constructors
declares an instance variable which is final and has no initializing
expression. With https://github.com/dart-lang/language/pull/1130 this
is an error, and that error is expected by the test. Also test that
it is not an error to have an uninitialized final variable which is
abstract or external.

Change-Id: I6c4a46393f46587448612bd91fb99fa65f89704c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157490
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-08-07 18:19:35 +00:00
Régis Crelier fac552a45c Revert "[VM/runtime] Fix computation of the hash of recursive types."
This reverts commit a528b19d2c.

Reason for revert: Failures in precompiled mode.

Original change's description:
> [VM/runtime] Fix computation of the hash of recursive types.
> 
> When computing the hash of a type, only include the hashes of the type arguments corresponding to the type parameters of the type's class and not of the whole type argument vector, otherwise, the variable location of TypeRefs in the base class type arguments may result in different hashes.
> 
> Add a regression test (this test was not failing in all configurations, since the issue becomes visible depending on the order in which types are loaded and finalized).
> 
> This fixes issue https://github.com/dart-lang/sdk/issues/42954
> 
> Small improvement: pick hash value 1 for a vector of dynamic types, so it can be cached and not recomputed repeatedly, which was the case with value 0.
> 
> Change-Id: I3468952cbf61944a82cf8e00efbf4952bd831fbe
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157563
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Régis Crelier <regis@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com,asiva@google.com,regis@google.com

Change-Id: I904e7043fa175d03bb9af56a9346b097b883c7a0
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157700
Reviewed-by: Régis Crelier <regis@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-07 02:15:52 +00:00
Regis Crelier a528b19d2c [VM/runtime] Fix computation of the hash of recursive types.
When computing the hash of a type, only include the hashes of the type arguments corresponding to the type parameters of the type's class and not of the whole type argument vector, otherwise, the variable location of TypeRefs in the base class type arguments may result in different hashes.

Add a regression test (this test was not failing in all configurations, since the issue becomes visible depending on the order in which types are loaded and finalized).

This fixes issue https://github.com/dart-lang/sdk/issues/42954

Small improvement: pick hash value 1 for a vector of dynamic types, so it can be cached and not recomputed repeatedly, which was the case with value 0.

Change-Id: I3468952cbf61944a82cf8e00efbf4952bd831fbe
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157563
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
2020-08-07 00:01:49 +00:00
Vyacheslav Egorov 2c33d87a69 [vm/compiler] Fix lazy deopt from LoadField
When converting InstanceCall to LoadField don't adjust deoptimization
environment because when we deoptimize from LoadField back to
InstanceCall we would expect to have receiver on the stack.

This is a different situation from LoadField to LoadField lazy
deoptimization in which case receiver should not be on the stack.

Regression test provided by Ryan.

Fixed: 42900
Change-Id: I6041ff02abf22a2bae0fdcd65d5b49ef8aec6204
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157182
Commit-Queue: Vyacheslav Egorov <vegorov@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2020-08-06 15:45:24 +00:00
Johnni Winther ad9c73cb32 [cfe] Use promoted type as type context in variable assignment
Closes #41698

Change-Id: Iea87c770b560f6f72f9382f06615d99ad2be0c3a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155764
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
2020-08-03 10:37:41 +00:00
Konstantin Shcheglov 46f6abe42f Add actual errors to language/unsorted/external_test.dart
R=brianwilkerson@google.com

Change-Id: If80af2e150df4270af8121464d108b669d98d909
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
2020-07-31 19:26:09 +00:00
Sam Rawlins b8ce4baf7e Remove 'checked mode' from checked_mode_compile_time_errors
Change-Id: I6576eb186149d540ce2dbc0e0aab7177ff4727be
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156484
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2020-07-31 19:20:58 +00:00
Stephen Adams 30a7f00f0b [dart2js] Add --null-assertions flag
With --enable-asserts, does automatic debug assertion insertion:
https://github.com/dart-lang/language/blob/master/accepted/future-releases/nnbd/feature-specification.md#automatic-debug-assertion-insertion

Without --enable-asserts, does a NullCheck instead of an assert.

Change-Id: I57b8c9ce9e7605b9d2355b1d96a10db3fd631917

Fixes: 42403
Change-Id: I57b8c9ce9e7605b9d2355b1d96a10db3fd631917
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156044
Commit-Queue: Stephen Adams <sra@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
2020-07-30 22:13:04 +00:00
Sam Rawlins f23f450e11 Analyzer: Move CONST_CONSTRUCTOR_PARAM_TYPE_MISMATCH to compile-time
Many of the tests were highly redundant. Subtyping has been
consolidated, so the tests don't need to cover a dozen different ways
to subtype a class.

Change-Id: I04448790d3a74690d0edb57f15146a6c3b8f2173
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156400
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2020-07-30 00:34:29 +00:00
Konstantin Shcheglov 219107cca0 Report INVALID_ASSIGNMENT on the cascade target.
https://dart-review.googlesource.com/c/sdk/+/155380 has tests that
show that it is otherwise hard to specify where the offending
expression is.

Change-Id: I8cdbc3d974148d644b75889a8afd921a2a2716cd
Bug: https://github.com/dart-lang/sdk/issues/42865
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156067
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-29 23:04:49 +00:00
Konstantin Shcheglov d5845d255c Fix several language/ tests.
Change-Id: I38946733f298bea75e65faff20c6d911e6bd37f5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154361
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-29 17:10:55 +00:00
Leaf Petersen fcbf4932be Add tests for mixed mode upper bound.
Tests for the null safety specification change landed
in https://github.com/dart-lang/language/pull/1109 .

Change-Id: I5e9388a99a8a121870b5dd8a844db4f9857a9eea
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155380
Reviewed-by: Paul Berry <paulberry@google.com>
2020-07-29 05:04:38 +00:00
Nicholas Shahan 57a8ffd6b1 [ddc] Fix is type tests on nullable types
Types that are represented by primitives in JS were dropping the
nullable portion when used in `is` type tests.

Add regression test expectations for all built in dart types and
a version of the tests that can run with sound null safety.

Change-Id: I155a673ac23132eb06749d890bce272db3248b33
Fixes: https://github.com/dart-lang/sdk/issues/42851
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/156060
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2020-07-27 23:32:18 +00:00
Konstantin Shcheglov 8de8a1c226 Move codes from StaticTypeWarningCode into CompileTimeErrorCode.
They are all errors now.

Change-Id: If48d38e38e845fd5b5a950dd5514bf1cbbce03d8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155880
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-27 16:44:15 +00:00
Konstantin Shcheglov ba92b78acd Move errors from StaticWarningCode to CompileTimeErrorCode.
Bug: https://github.com/dart-lang/sdk/issues/42821
Change-Id: I153c48d7a2e4a02026928e6203aacf8f2dc029ba
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155849
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
2020-07-26 04:19:25 +00:00