Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnmodifiableMapMixin and others aren't Dart3-ready #276

Open
oprypin opened this issue Mar 27, 2023 · 12 comments
Open

UnmodifiableMapMixin and others aren't Dart3-ready #276

oprypin opened this issue Mar 27, 2023 · 12 comments
Assignees
Labels
3.0 needs-info Additional information needed from the issue author

Comments

@oprypin
Copy link

oprypin commented Mar 27, 2023

UnmodifiableMapMixin should become a mixin or mixin class. Otherwise it is not ready for use with Dart 3 / prefer_mixin.
All usages of it are expected to be within a with clause.

Others that I noticed are NonGrowableListMixin, UnmodifiableSetMixin

@lrhn
Copy link
Member

lrhn commented Mar 27, 2023

https://dart-review.googlesource.com/c/sdk/+/288240 should hopefully land soon-ish.

@oprypin
Copy link
Author

oprypin commented Mar 27, 2023

Is that related? This is about 'package:collection'

@lrhn
Copy link
Member

lrhn commented Mar 27, 2023

(Already updated the URL, pasted the wrong one originally.)

@oprypin
Copy link
Author

oprypin commented Mar 27, 2023

🙂 I think it's still different - 'dart:collection' vs 'package:collection'

@lrhn
Copy link
Member

lrhn commented Mar 27, 2023

Argh. My bad. Wrong issue tracker entirely. (Naming footgun!)

Yes, yes they should.

@lrhn lrhn added the 3.0 label Mar 27, 2023
@oprypin
Copy link
Author

oprypin commented Apr 19, 2023

Ping on this issue. I think this is high priority to resolve and make a release of this library ahead of Dart 3.

Also cc @mit-mit @devoncarew

@lrhn
Copy link
Member

lrhn commented May 3, 2023

There is technically no reason to eagerly change anything, since pre-3.0 code classes can still be used as mixins without the mixin modifier. As long as this package's min-SDK is 2.18.0, mixin in should keep workin.

It's only an issue if someone tries to interpret the pre-3.0 code as post-3.0 code, ignoring the languge-version of the pubspec, which is not a safe thing to do since 3.0 is a breaking change for the language.
(And I believe the case where that was happening is no longer an issue, so we're not in any rush to release a 3.0 version.)

It's another issue that migrating the package to 3.0 properly should, rightfully, mean a major version increment.
Those are harder to release.

@dannnnthemannnn
Copy link

Hey all, I'm trying to use collections.dart and am getting errors like:

packages/collection/src/boollist.dart:231:50:
Error: The class 'NonGrowableListMixin' can't be used as a mixin because it isn't a mixin class nor a mixin.
class _NonGrowableBoolList extends BoolList with NonGrowableListMixin {
This is pulled in via transitive dependencies.

My dart version:

dart --version
Dart SDK version: 3.4.0 (stable) (Mon May 6 07:59:58 2024 -0700) on "macos_arm64"

I see this package says its SDK is ^3.1 in the pubspec.yaml.

Am I doing something wrong or is there a way to get this to continue working? I am using the dart associated with the latest version of flutter

My build command is: dart run build_runner build --output=build

@lrhn
Copy link
Member

lrhn commented May 21, 2024

Are you using the 1.19.0-wip version, which hasn't been released (or completed) yet?
The most recent release is 1.18.0, which uses SDK 2.18.

@dannnnthemannnn
Copy link

Ah I am using 1.18. So its not possible currently to use dart:collection with the current dart version? Curious how does flutter work when the current packaged dart version with flutter stable is 3.4?

@lrhn
Copy link
Member

lrhn commented May 22, 2024

You should be able to use package:collection 1.18 with any SDK that supports language version 2.18. All 3.X SDKs supports that.

If you do so, you should not get any error.
Pre-3.0 classes with no superclass can be used as mixins, both by pre- and post-3.0 code.

If it cannot, we have a bug.

I cannot reproduce the issue. Using tip-of-tree SDK, in a fresh dart package (dart create coltest) with an SDK version of ^3.3.0 and dependency collection: 1.18.0, the following code has no error:

import "dart:collection";
import "package:collection/collection.dart";

abstract class C extends ListBase<int> with NonGrowableListMixin<int> {}

Any chance you can show an entire compilable file that has the error, and/or check the language version of package:collection in .dart_tool/package_config.json?

@lrhn lrhn added the needs-info Additional information needed from the issue author label May 22, 2024
@dannnnthemannnn
Copy link

I am building using build runner/dart2js. The language version in collection says

{
  "name": "collection",
  "rootUri": "file:///Users/dannyfranklin/.pub-cache/git/collection-d51223f93e109408666606fbb13a37b79a1ec2c2/",
  "packageUri": "lib/",
  "languageVersion": "3.0"
},

I am building using flutter pub run build_runner build --output=build
and my build.

My build.yaml

targets:
  $default:
    sources:
      - "$package$"
      - "node/**"
      - "lib/**"
      - "js/**"
    builders:
      build_node_compilers|entrypoint:
        generate_for:
        - node/**
        options:
          compiler: dart2js
          # List any dart2js specific args here, or omit it.
          dart2js_args:
            - -O0
      json_serializable:
        options:
          explicit_to_json: true

My pubspec env:

environment:
  sdk: ">=2.18.0 <3.0.0"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.0 needs-info Additional information needed from the issue author
Projects
None yet
Development

No branches or pull requests

3 participants