Commit Graph

4770 Commits

Author SHA1 Message Date
Dmitry Stefantsov 19297a9a42 [cfe] Implement missing bound checks for nonfunction type aliases
Closes #45519.

Bug: https://github.com/dart-lang/sdk/issues/45519
Change-Id: I0492e83ebf605eaa1355d7e472bc28050dc5588c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193500
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-31 19:21:42 +00:00
Johnni Winther 3c2dfd7975 [cfe] Check bounds on function invocation
Closes #45464

Change-Id: I0fb3abf66c2119147ddd9413792e6f5dc151c31c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193660
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-31 16:33:49 +00:00
Paul Berry e4fbad8744 Flow analysis: fix "why not promoted" info for nullable_expression_call_error
Previously, I only did the proper flow analysis integration in the
case where `useNewMethodInvocationEncoding` was true, so these cases
didn't work when it was false.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I6e126f4b8dc9a159087669c3d6ffa332373f8ce4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193590
Commit-Queue: Paul Berry <paulberry@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-31 15:20:28 +00:00
Johnni Winther 1eda15854d [cfe] Allow experiments only in current sdk version
Experiments that have not be enabled by default should only be allowed
in the current version of the sdk.

Closes #45460

Change-Id: I159f390ac85fe37943920717ce11a4c817d5b4a9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193480
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-31 15:20:08 +00:00
Johnni Winther 19ab1fd800 [cfe] Report error on nullable supertypes through type aliases
Closes #43261
Closes #45423

Change-Id: Ia22975f9cd8fd3835b0feda82c6d5310098b605c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193501
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-31 12:34:13 +00:00
Johnni Winther 0a1a5276ba [cfe] Ensure that types are also resolved in case of parser recovery
Closes #45490

Change-Id: I447a637a13fc9a32528a79f0f036c0aa6f74abb5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193407
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-30 14:56:38 +00:00
Dmitry Stefantsov 3a21e08d9e Reland [cfe] Remember built TypedefTypes for late bounds checks
Closes #45487.

Bug: https://github.com/dart-lang/sdk/issues/45487
Change-Id: Idf68c051260b47e9d830c5de0cba977e2f85b427
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193401
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-30 13:49:18 +00:00
Johnni Winther 13556d623f [cfe] Add DartType.toNonNull
Add helper on DartType to compute the `NonNull` of a type and use this
instead of `withDeclaredNullability(Nullability.nonNullable).

Includes a fix in the computation of NonNull of FutureOr.

TEST=existing

Change-Id: I3399cbf89c7d3f3e90f1315b01f40957e798a1b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193400
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-30 10:25:28 +00:00
Kallen Tu 5b3a5acf01 [cfe] Switch statements for const functions.
Change-Id: I1194f9091b74ba3e288d5e7bd386c204fa25c837
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193360
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2021-03-30 03:56:58 +00:00
Dmitry Stefantsov 9008fc0eaf Revert "[cfe] Remember built TypedefTypes for late bounds checks"
This reverts commit ce841aa40c.

Reason for revert: a crash in google3.

Original change's description:
> [cfe] Remember built TypedefTypes for late bounds checks
>
> Bug: https://github.com/dart-lang/sdk/issues/45334
> Change-Id: Idbc823ecc688f2679134c757dcf7a7ad12a02e24
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192146
> Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
> Reviewed-by: Johnni Winther <johnniwinther@google.com>

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: https://github.com/dart-lang/sdk/issues/45334
Change-Id: I9ba9d02a29e17b58ddbf313dce70af8c9498c1a0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193305
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-03-29 13:27:47 +00:00
Paul Berry 79bf4f33ae Clean up nomenclature around whyNotPromoted.
We used to have some variables called `whyNotPromoted` and others
called `whyNotPromotedInfo`, with no obvious distinction between the
two names.  Now we use `whyNotPromoted` for variables holding the map
returned by `FlowAnalysis.whyNotPromoted`, and `whyNotPromotedList`
for variables holding a list of such maps.

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I3823d16ef908a833e4d4526ae1c3576c73ecf1fb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193083
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-03-26 00:29:24 +00:00
Kallen Tu 51b0832516 Language tests for erroneous conditions in control flow statements.
Conditions which are not bools. The error checking should be handled by the compiler so asserts added just in case.

Change-Id: Ia53c7aa017300f5afbfe636604855e4183e1d0a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192580
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-25 23:21:34 +00:00
Dmitry Stefantsov ce841aa40c [cfe] Remember built TypedefTypes for late bounds checks
Bug: https://github.com/dart-lang/sdk/issues/45334
Change-Id: Idbc823ecc688f2679134c757dcf7a7ad12a02e24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192146
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-25 20:31:24 +00:00
Dmitry Stefantsov e9d7ad78e4 [cfe] Check bounds in aliased constructor calls
Bug: https://github.com/dart-lang/sdk/issues/45334
Change-Id: Ia2a9d154dba21d445f8f821988580fbf4249cf24
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192925
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-25 18:04:04 +00:00
Erik Ernst 6db2f7a2f6 Correct implementation of expand-to-type-variable error check
Bug: #45351
Change-Id: I0f7a813c8da8ce2f60cdcd3d81d854e75556130f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192743
Commit-Queue: Erik Ernst <eernst@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-25 16:28:34 +00:00
Kallen Tu 045813c1f3 [cfe] Asserts for const functions.
Basic assert statements, inline functions in the future. AssertBlocks are not supported with const functions.

Change-Id: Ic831fc4d76db0403a30577b9d00c629237148581
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192800
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-24 16:38:41 +00:00
Sam Rawlins 3efcdb3ff0 front_end: Remove unnecessary import
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I631483a90d89268c0ffd75ee2e1c27ba19f084cb
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192609
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-03-24 13:30:49 +00:00
Johnni Winther 92e237c835 [cfe,dartdevc,dart2js] Use InstanceGetterInvocation for getter/field invocation
The web compilers don't support getter/field invocation encoded as a
FunctionInvocation on an InstanceGet because it doesn't work for
getter/field invocation of js-interop properties, since the InstanceGet
wouldn't result in a Dart function but just JavaScript function.

To support this in the new method invocation encoding, a special
expression, InstanceGetterInvocation, is used to encode getter/field
invocations in dart2js and ddc.

Change-Id: I21da8e8686f66ae4ce4d44245073b9e424f975b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192181
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-23 09:49:06 +00:00
Johnni Winther 0de315c146 [cfe] Compute variance for type parameters on duplicate typedefs
Change-Id: I6e4a05911c77d26f1fb440ec8e90c13e783926e9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192147
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-23 07:32:26 +00:00
Kallen Tu 9e5a6c1568 [cfe] Do-while statements for const functions.
Change-Id: I881fb535ef76e564ab76c5fc661d3adbbe5aed0f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192401
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-22 22:19:45 +00:00
Kallen Tu 45c9d8a25e [cfe] Enable recursive function calls for const functions.
Change-Id: Ia164adaf5da313cae4db2b3b326a909e57d8c07c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192200
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-19 17:56:17 +00:00
Johnni Winther 5c65c68669 [cfe] Handle cyclic bounds on generic function types as type arguments
This also handles reporting of cyclic bounds in parts and sets the
bound of a cyclic type parameter to InvalidType to avoid looping on
the bound later, as for instance in computation of NORM.

Closes #45330

Change-Id: Ida20dc5b44b08a6f8674a402d801314a9172fa8a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/192142
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-19 17:54:37 +00:00
Daco Harkes 77dc74bcd5 [vm/ffi] Support packed Structs
Closes: https://github.com/dart-lang/sdk/issues/38158

This CL implements unaligned access for float/double on arm32, but does
not expose it in an API. Rather it only uses these loads/stores inside
the getters and setters of packed structs.
Bug: https://github.com/dart-lang/sdk/issues/45009

Besides unaligned access for float/double, this CL is mostly a CFE
change. The only VM change is reading the packing in the
`_FfiStructLayout` annotation.

The implementation of using the packing in the VM, and analyzer changes
have landed separately in earlier CLs.

tools/test.py ffi ffi_2
TEST=tests/ffi(_2)/(.*)by_value_(*.)_test.dart

Change-Id: Ic3106ecc626d2e30674a49bf03f65ae12d2b3502
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/186143
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-03-19 15:34:42 +00:00
Johnni Winther 9ad76fe7bd [cfe] Support annotations on function type parameters
The fix includes processing of type parameters elsewhere and also
adding support for annotations on extensions.

Closes #28981

TEST=existing

Change-Id: I71ab5640bd3a16f4a024b6edd047a525eed1c399
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191404
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-19 11:52:57 +00:00
Paul Berry 681d3e2a43 Allow the expensive parts of "why not promoted" computation to be deferred.
This is necessary because `whyNotPromoted` needs to be called right
after visiting a subexpression, but it's not always possible to tell
that the type of that subexpression will result in an error until more
code has been visited.

Change-Id: If44e2bb55612c1ba7996b523c3ec078d7b80c865
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
2021-03-18 19:52:13 +00:00
Kallen Tu 3c5c1cd3f4 [cfe] Break, continues and labels for const functions.
Change-Id: Id8fce4088042b4acf9eadebe7aa99abd5565a471
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191680
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-18 17:06:13 +00:00
Johnni Winther 12f510fbd1 [dart2js] Use new method invocation encoding
Change-Id: Iab73f25a19fe8718cb68327fef5878d25b735030
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188523
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Mayank Patke <fishythefish@google.com>
2021-03-17 17:26:25 +00:00
Sam Rawlins 7465b17ad7 front_end: Remove unnecessary imports
Bug: https://github.com/dart-lang/sdk/issues/44569
Change-Id: I0dd5d176a95289333cd42f87f49d7820c54bbe38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191470
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
2021-03-17 16:48:40 +00:00
Kallen Tu 7ff1aebc2d [cfe] While loops for const functions.
Change-Id: I7979fa8b50a74f9e423f19805a793a0c25609abd
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191580
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-17 16:11:43 +00:00
Kallen Tu 54f8b6fb54 [cfe] Basic for loops for const functions.
Basic for loops with tests, breaks/continues coming in a later CL.

Change-Id: I28f832ef80689a562da99f60d682bf8e4c630697
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191340
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-17 14:53:22 +00:00
Dmitry Stefantsov e64daf805f [cfe] Handle boudness type variables in results from i2b
Closes #45317.

Bug: https://github.com/dart-lang/sdk/issues/45317
Change-Id: Ib6144778a11dc837c74b4b7992c41dbe2d654946
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191260
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
2021-03-17 10:48:31 +00:00
Kallen Tu 00b6a815d9 [cfe] AbortStatus in statement executor for constants.
Change-Id: I96d5a7bc7aed69898e2c8bf048aeadf3b02387c6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/191100
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-16 15:56:51 +00:00
Dmitry Stefantsov d6b79dab6c [cfe] Correct argument count in extension member errors
Closes #45204.

Bug: https://github.com/dart-lang/sdk/issues/45204
Change-Id: I5295704a8d470e639fe346dbbbf80ad28ff614a6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190520
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-15 10:46:00 +00:00
Kallen Tu a7e5965495 [cfe] If statements for const functions.
Change-Id: If4449eb6613c7a2b53119ed2e8d3f3042624ccd1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190800
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-12 21:09:08 +00:00
Dmitry Stefantsov 8ddc7465a8 [cfe] Move ExtensionType into pkg/kernel/lib/ast.dart
Change-Id: I2e8231dad00accafb09d1ec88416242d3d5815a4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190483
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-12 19:02:27 +00:00
Kallen Tu 494aaaab39 [cfe] Variable assignments (VariableSet) for const functions.
Change-Id: Iab23493fc09b8fdad78968d905ac8f28e1236aa4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190620
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2021-03-11 23:14:41 +00:00
Johnni Winther 1aa6f00107 [kernel] Refactor CanonicalName/Reference integration
The CL is a step towards have a more restricted and wellstructured
handled of references and canonical names.

The CL moves Reference to canonical_name.dart and makes
CanonicalName.reference private, and replaces CanonicalName.getReference
with a 'reference' getter.

It also removes NamedNode.canonicalName, Field.getterCanonicalName and
Field.setterCanonicalName so that these can only be accessed through the
corresponding reference. This is to reduce the reliance on the
canonical names which, ideally, should only be part of serialization and
deserialization.

TEST=existing

Change-Id: I955fb7d52d4e112d8741f7c12dcf38b74ae0c91a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190442
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Jens Johansen <jensj@google.com>
2021-03-10 15:39:28 +00:00
Paul Berry c509ad1e41 Change "could not" to "couldn't" in error messages
See comments at
https://dart-review.googlesource.com/c/sdk/+/186320/4/pkg/analyzer/lib/src/generated/resolver.dart#3423.
On the recommendation of the documentation team, we use a more
informal tone in messages.

Change-Id: I0c243669ebd91b8f4a745530582e0f829769a754
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189100
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-10 15:26:38 +00:00
Kallen Tu 3210fb4306 [cfe] Environment parents and block tests for const functions.
Fixed up block environment and added tests for them.

Change-Id: I97375c90c9244f6dcf8294dc11b0d4e70697d114
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190320
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-10 15:23:18 +00:00
Paul Berry b661bf12c5 Front end: Additional "why not promoted" functionality.
This CL implements "why not promoted" functionality in the front end
for the following scenarios:
- null iterable in for-loop
- null iterable in yield* statement
- null iterable or map after spread (`...`) operator

Bug: https://github.com/dart-lang/sdk/issues/44898
Change-Id: I471b8bf558341514207fad527dde009f1372182c
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188160
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-10 14:52:19 +00:00
Paul Berry 73f9d0cd26 Flow analysis: Remove unnecessary argument from tryFinallyStatement_end.
Flow analysis stopped using this argument (the AST node for the
finally block) some time ago, but I kept it around so I could assert
that clients didn't unnecessarily store assigned variables info for
it.  It's been long enough now that we can eliminate this code
entirely.

Change-Id: I8c64e2b4fc5b154f441ec2d057637f3dc9ced277
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/190060
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-10 13:14:08 +00:00
Kallen Tu d1fd3c6cb6 [cfe] Local functions for const functions.
Change-Id: I9ad3c36c4d515afe1def3f32244dc15b291d4011
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189980
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-10 01:07:32 +00:00
Dmitry Stefantsov a65f9357f8 [cfe] Add resolution for other member kinds for extension types
Change-Id: Ief5b7da1e06d0b37327fb62d29c967bcfb2cbdf6
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189208
Commit-Queue: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
2021-03-09 12:49:40 +00:00
Daco Harkes ffa5d16ae7 [vm/ffi] Support multi-dimensional inline arrays
This CL only changes dart:ffi API, CFE, and analyzer. No VM changes
were needed because the dimensions of inline arrays can be flattened
before passing them to the VM. The multi-dimensionality does not
impact the ABI.

Closes: https://github.com/dart-lang/sdk/issues/45023

TEST=pkg/analyzer/test/src/diagnostics/size_annotation_dimensions_test.dart
TEST=pkg/front_end/testcases/nnbd/ffi_struct_inline_array_multi_dimensional.dart
TEST=tests/ffi/function_structs_by_value_generated_test.dart
TEST=tests/ffi/inline_array_multi_dimensional_test.dart

Change-Id: Ica2c01fccbea7e513879365b34086d8968b54c5b
Cq-Include-Trybots: luci.dart.try:dart-sdk-linux-try,dart-sdk-mac-try,dart-sdk-win-try,vm-ffi-android-debug-arm-try,vm-ffi-android-debug-arm64-try,vm-kernel-asan-linux-release-x64-try,vm-kernel-mac-debug-x64-try,vm-kernel-linux-debug-ia32-try,vm-kernel-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-x64-try,vm-kernel-nnbd-linux-debug-ia32-try,vm-kernel-nnbd-mac-release-x64-try,vm-kernel-nnbd-win-debug-x64-try,vm-kernel-precomp-linux-debug-x64-try,vm-kernel-precomp-linux-debug-simarm_x64-try,vm-kernel-precomp-nnbd-linux-debug-x64-try,vm-kernel-precomp-win-release-x64-try,vm-kernel-reload-linux-debug-x64-try,vm-kernel-reload-rollback-linux-debug-x64-try,vm-kernel-win-debug-x64-try,vm-kernel-win-debug-ia32-try,vm-precomp-ffi-qemu-linux-release-arm-try,vm-kernel-precomp-obfuscate-linux-release-x64-try,vm-kernel-msan-linux-release-x64-try,vm-kernel-precomp-msan-linux-release-x64-try,vm-kernel-precomp-android-release-arm_x64-try,analyzer-analysis-server-linux-try
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188286
Commit-Queue: Daco Harkes <dacoharkes@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
2021-03-09 10:50:17 +00:00
Johnni Winther 67a810c758 [cfe] Make constant evaluator implement ExpressionVisitor
Change-Id: Id0aa5e808857798d7403a2733f69c2fe7bb3842e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189207
Reviewed-by: Jens Johansen <jensj@google.com>
Commit-Queue: Johnni Winther <johnniwinther@google.com>
2021-03-09 08:05:56 +00:00
Kallen Tu 0ac716d098 [cfe] Variable declarations for const functions.
Change-Id: I085d789125e80dd2b45df9a55f4eaea28c98fd66
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189400
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Reviewed-by: Jake Macdonald <jakemac@google.com>
2021-03-08 23:34:23 +00:00
Johnni Winther 01b0947a6d [kernel] Update kernel encodings
* Add InstanceGetterInvocation for getter/field invocation in web
  backends
* Add localFunction getter to LocalFunctionInvocation
* Remove isNot from EqualsCall and EqualsNull - the encoding didn't
  carry its weight.
* Remove uses of Name.name
* Remove BottomType code from VM

TEST=existing

Change-Id: I99d05d35b9ef193d092cc151c99ad472dbd60834
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188725
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-08 11:29:51 +00:00
Kallen Tu b683098fde [cfe] Execute statements with StatementConstantEvaluator.
Altered the structure of the statement visitors now that ConstantEvaluator is an expression visitor. Currently uses the environment from the prior exprEvaluator, but will change in the future when needed.

No new const functionality, just set up for future ones.

Tests renamed so they actually run now.

Change-Id: Ic5914b0fc700aadeb0dcb28c08593f88e38582a2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189220
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
Commit-Queue: Kallen Tu <kallentu@google.com>
2021-03-06 01:16:26 +00:00
Kallen Tu e28a53a781 Added IntermediateValue constant results, EvaluationReferences to store values.
Pre-work for variable declarations and method invocation. Storing values in locations (refs) and having the ability to update the values.

Change-Id: I682c139dfebbc4ef6f5032d4f53f29f08b8ceeb8
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188500
Commit-Queue: Kallen Tu <kallentu@google.com>
Reviewed-by: Dmitry Stefantsov <dmitryas@google.com>
2021-03-04 18:27:59 +00:00
Paul Berry 219fe27e3e Front end: Fix follow-on error arising from ill-typed spread element.
When the CFE encounters an ill-typed spread element in an ambiguous
set/map literal, it replaces it with a synthetic MapEntry object
pointing to an InvalidExpression.  If there is no non-synthetic
MapEntry in the set/map, and it is decided to disambiguate to a set,
then all of the entries are fed into the `convertToElement` method.
Before this CL, this method would see the synthetic MapEntry and
assume the user had explicitly written a key-value pair in a set
literal, so it would try to report the error `Expected ',' before
this` at the location of the `:` in the key-value pair.  But since the
MapEntry was synthetic, there was no `:` and the message was very
confusing.

This CL changes `convertToElement` so that it detects when a MapEntry
has arisen from an error, and avoids creating a follow-on error.

Fixes #45174.

Bug: https://github.com/dart-lang/sdk/issues/45174
Change-Id: I37dc82a130b4bf858b3fb7411bb9c64f7450bd16
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/188940
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-03-04 15:52:57 +00:00