From c60e5043028235b5cd2ac8b9e61883768f2f2c01 Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Thu, 29 Mar 2018 23:52:33 -0700 Subject: [PATCH] Override dependencies of locked packages Partially addresses #1853 --- lib/src/solver/package_lister.dart | 1 + test/version_solver_test.dart | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/lib/src/solver/package_lister.dart b/lib/src/solver/package_lister.dart index 0ee7a9224..8b5dc7d7f 100644 --- a/lib/src/solver/package_lister.dart +++ b/lib/src/solver/package_lister.dart @@ -227,6 +227,7 @@ class PackageLister { return incompatibilities; } else { return pubspec.dependencies.values + .where((range) => !_overriddenPackages.contains(range.name)) .map((range) => _dependency(depender, range)) .toList(); } diff --git a/test/version_solver_test.dart b/test/version_solver_test.dart index 30be6daa5..97bd869c6 100644 --- a/test/version_solver_test.dart +++ b/test/version_solver_test.dart @@ -1797,6 +1797,29 @@ void override() { await expectResolves(result: {'foo': '0.0.0'}); }); + + // Regression test for #1853 + test("overrides a locked package's dependency", () async { + await servePackages((builder) { + builder.serve("foo", "1.2.3", deps: {"bar": "1.2.3"}); + builder.serve("bar", "1.2.3"); + builder.serve("bar", "0.0.1"); + }); + + await d.appDir({"foo": "any"}).create(); + + await expectResolves(result: {'foo': '1.2.3', 'bar': '1.2.3'}); + + await d.dir(appPath, [ + d.pubspec({ + "name": "myapp", + "dependencies": {"foo": "any"}, + "dependency_overrides": {"bar": '0.0.1'} + }) + ]).create(); + + await expectResolves(result: {'foo': '1.2.3', 'bar': '0.0.1'}); + }); } void downgrade() {