From b144eaa0724188f2d73bf3eb8ee659d088b35325 Mon Sep 17 00:00:00 2001 From: Jonas Finnemann Jensen Date: Tue, 31 May 2022 18:22:26 +0200 Subject: [PATCH 1/3] Fix `dart pub login` due to unexpected `null` in response. Users who was already logged was able to continue publish packages, but displaying the login status using `dart pub login` was broken. Attempts to login would also cause a crash after successful authentication, before credentials were saved. The command crashed because the metadata end-point returned `null` for the name property. This fix handles invalid responses more gracefully, and handles the case where `name` is `null`, by not displaying the name. Change-Id: I29ae92ced255565f2d270b1cdf86522fb42a8a69 --- CHANGELOG.md | 2 ++ DEPS | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 880028a91d50..aa1a5a6a2b21 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,11 @@ This is a patch release that fixes: - a Dart VM compiler crash (issue [#100375][]). - code completion when writing method overrides (issue [#49086][]). +- `dart pub login` crashes due to `null` response (issue [pub#3424][]) [#100375]: https://github.com/flutter/flutter/issues/100375 [#49086]: https://github.com/dart-lang/sdk/issues/49086 +[pub#3424]: https://github.com/dart-lang/pub/issues/3424 ## 2.17.1 - 2022-05-18 diff --git a/DEPS b/DEPS index 5471a60430e6..257d408a820d 100644 --- a/DEPS +++ b/DEPS @@ -141,7 +141,7 @@ vars = { "pool_rev": "7abe634002a1ba8a0928eded086062f1307ccfae", "process_rev": "56ece43b53b64c63ae51ec184b76bd5360c28d0b", "protobuf_rev": "c1eb6cb51af39ccbaa1a8e19349546586a5c8e31", - "pub_rev": "a949b329b1b51f5f3973a790e0a0a45897d837de", + "pub_rev": "c66381c51147e3a8fb64c6f63e481c990ab9aa94", "pub_semver_rev": "ea6c54019948dc03042c595ce9413e17aaf7aa38", "root_certificates_rev": "692f6d6488af68e0121317a9c2c9eb393eb0ee50", "rust_revision": "b7856f695d65a8ebc846754f97d15814bcb1c244", From 59ac492467fa693b1643ed0cedcf5040f21d7b65 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Wed, 25 May 2022 10:07:38 -0700 Subject: [PATCH 2/3] [CP] Issue 49097. Resolve constants in enhanced enum constructors/methods. Bug: https://github.com/dart-lang/sdk/issues/49097 Change-Id: I9fccbd2f70d94f7d6cfe780b8d4fadf1708eb7a1 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/245909 Reviewed-by: Brian Wilkerson Commit-Queue: Konstantin Shcheglov --- .../src/summary2/default_value_resolver.dart | 1 + .../non_constant_default_value_test.dart | 19 +++++ .../test/src/summary/elements_test.dart | 73 +++++++++++++++++++ 3 files changed, 93 insertions(+) diff --git a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart index 632a6c4d6feb..8170e4242a12 100644 --- a/pkg/analyzer/lib/src/summary2/default_value_resolver.dart +++ b/pkg/analyzer/lib/src/summary2/default_value_resolver.dart @@ -23,6 +23,7 @@ class DefaultValueResolver { for (var unitElement in _libraryElement.units.impl) { _UnitContext(unitElement) ..forEach(unitElement.classes, _class) + ..forEach(unitElement.enums, _class) ..forEach(unitElement.extensions, _extension) ..forEach(unitElement.functions, _executable) ..forEach(unitElement.mixins, _class); diff --git a/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart b/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart index 66cd70958e1d..957f0b8097dc 100644 --- a/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart +++ b/pkg/analyzer/test/src/diagnostics/non_constant_default_value_test.dart @@ -98,6 +98,25 @@ class A { ]); } + test_enum_issue49097() async { + newFile2('$testPackageLibPath/a.dart', r''' +class A { + static const foo = A(); + static const bar = A(); + const A(); +} +'''); + await assertNoErrorsInCode(r''' +import 'a.dart'; + +enum E { + v(f: A.foo); + final A f; + const E({this.f = A.bar}); +} +'''); + } + test_function_named() async { await assertErrorsInCode(r''' int y = 0; diff --git a/pkg/analyzer/test/src/summary/elements_test.dart b/pkg/analyzer/test/src/summary/elements_test.dart index fdca05f7bc7f..4894374a8357 100644 --- a/pkg/analyzer/test/src/summary/elements_test.dart +++ b/pkg/analyzer/test/src/summary/elements_test.dart @@ -17847,6 +17847,79 @@ library '''); } + test_enum_constructor_fieldFormal_optionalNamed_defaultValue() async { + var library = await buildLibrary(r''' +enum E { + v; + final int x; + const E({this.x = 1 + 2}); +} +'''); + checkElementText(library, r''' +library + definingUnit + enums + enum E @5 + supertype: Enum + fields + static const enumConstant v @11 + type: E + constantInitializer + InstanceCreationExpression + constructorName: ConstructorName + type: NamedType + name: SimpleIdentifier + token: E @-1 + staticElement: self::@enum::E + staticType: null + type: E + staticElement: self::@enum::E::@constructor::• + argumentList: ArgumentList + leftParenthesis: ( @0 + rightParenthesis: ) @0 + staticType: E + synthetic static const values @-1 + type: List + constantInitializer + ListLiteral + leftBracket: [ @0 + elements + SimpleIdentifier + token: v @-1 + staticElement: self::@enum::E::@getter::v + staticType: E + rightBracket: ] @0 + staticType: List + final x @26 + type: int + constructors + const @37 + parameters + optionalNamed final this.x @45 + type: int + constantInitializer + BinaryExpression + leftOperand: IntegerLiteral + literal: 1 @49 + staticType: int + operator: + @51 + rightOperand: IntegerLiteral + literal: 2 @53 + staticType: int + staticElement: dart:core::@class::num::@method::+ + staticInvokeType: num Function(num) + staticType: int + field: self::@enum::E::@field::x + accessors + synthetic static get v @-1 + returnType: E + synthetic static get values @-1 + returnType: List + synthetic get x @-1 + returnType: int +'''); + } + test_enum_constructor_fieldFormal_typed_typed() async { var library = await buildLibrary(''' enum E { From e4481b78abf1f13c36578e14e76d29b60fd6ea9b Mon Sep 17 00:00:00 2001 From: William Hesse Date: Wed, 1 Jun 2022 10:43:34 +0200 Subject: [PATCH 3/3] [release] Add 2.17.3 release notes Change-Id: I92ba9f098153a52797c2e294e36cb197d7b69f48 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/246640 Reviewed-by: Alexander Thomas --- CHANGELOG.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aa1a5a6a2b21..b1291f6225ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,14 +1,16 @@ -## 2.17.2 - 2022-06-01 +## 2.17.3 - 2022-06-01 This is a patch release that fixes: - a Dart VM compiler crash (issue [#100375][]). -- code completion when writing method overrides (issue [#49086][]). -- `dart pub login` crashes due to `null` response (issue [pub#3424][]) +- code completion when writing method overrides (issue [#49027][]). +- the `dart pub login` command (issue [#3424][]). +- analysis of enhanced enums (issue [#49097][]). [#100375]: https://github.com/flutter/flutter/issues/100375 -[#49086]: https://github.com/dart-lang/sdk/issues/49086 -[pub#3424]: https://github.com/dart-lang/pub/issues/3424 +[#49027]: https://github.com/dart-lang/sdk/issues/49027 +[#3424]: https://github.com/dart-lang/pub/issues/3424 +[#49097]: https://github.com/dart-lang/sdk/issues/49097 ## 2.17.1 - 2022-05-18