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

"Error: The non-abstract class '_StaticTypeImpl' is missing implementations" #4406

Open
lukehutch opened this issue Jun 4, 2024 · 20 comments
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@lukehutch
Copy link

I just switched to the master channel of Flutter, and a project that uses the analyzer as a library (Serverpod) reports this error:

$ ../../../.pub-cache/hosted/pub.dev/analyzer-6.5.0/lib/src/summary2/macro_application.dart:1261:7: Error: The non-abstract class '_StaticTypeImpl' is missing implementations for these members:
 - StaticType.asInstanceOf
Try to either
 - provide an implementation,
 - inherit an implementation from a superclass or mixin,
 - mark the class as abstract, or
 - provide a 'noSuchMethod' implementation.

class _StaticTypeImpl implements macro.StaticType {
      ^^^^^^^^^^^^^^^
/opt/flutter/bin/cache/dart-sdk/pkg/_macros/lib/src/api/introspection.dart:119:28: Context: 'StaticType.asInstanceOf' is defined here.
  Future<NamedStaticType?> asInstanceOf(TypeDeclaration declaration);
                           ^^^^^^^^^^^^
  • Dart version 3.5.0 (build 3.5.0-214.0.dev)
  • Flutter version 3.23.0-13.0.pre.80 on channel master
  • Framework revision 5e448f4ce5 (10 hours ago), 2024-06-03 12:44:39 -0700
@otopba
Copy link

otopba commented Aug 7, 2024

Same here

@MrLightful
Copy link

Have it as well when using localizely/intl_utils.

Flutter 3.24.0 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 80c2e84975 (8 days ago) • 2024-07-30 23:06:49 +0700
Engine • revision b8800d88be
Tools • Dart 3.5.0 • DevTools 2.37.2

@hypen-flutter
Copy link

Same here

@bwilkerson
Copy link
Member

@scheglov @davidmorgan

@mobile-development-group-com

Same issue

@mobile-development-group-com
Copy link

mobile-development-group-com commented Aug 11, 2024

flutter doctor -v
[✓] Flutter (Channel stable, 3.24.0, on macOS 14.5 23F79 darwin-arm64, locale en-GB)
• Flutter version 3.24.0 on channel stable at /Users/.../Developer/flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 80c2e84975 (12 days ago), 2024-07-30 23:06:49 +0700
• Engine revision b8800d88be
• Dart version 3.5.0
• DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc1)
• Android SDK at /Users/.../Library/Android/sdk
• Platform android-34, build-tools 34.0.0-rc1
• Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15F31d
• CocoaPods version 1.15.2

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)

[✓] VS Code (version 1.85.1)
• VS Code at /Users/.../Downloads/Visual Studio Code.app/Contents
• Flutter extension version 3.84.0

[✓] Connected device (5 available)
• iPhone van User (mobile) • 00008110-001234E126A8AA1E • ios • iOS 17.5.1 21F90
• iPhone 15 Pro (mobile) • FC51A815-2573-4939-9464-23FF9E34753D • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-5 (simulator)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.5 23F79 darwin-arm64
• Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.5 23F79 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.100

[✓] Network resources
• All expected network resources are available.

• No issues found!

@davidmorgan
Copy link

I think to use Flutter from main you will need to also use a compatible (latest) analyzer version across anything that's using the analyzer as a library, @jakemac53 is there anything else we can advise people here? Thanks.

@MrLightful
Copy link

Have it as well when using localizely/intl_utils.

In my case, I was able to fix the issue by activating a global package again:

flutter pub global activate intl_utils

@jakemac53
Copy link
Contributor

Ah, yeah globally activated tools are an interesting use case... they probably do need to be re-activated to pick up versions that are compatible with the current SDK.

@TheComputerM
Copy link

For me, the issue got solved when I cleared the cache with dart pub cache clean and reinstalled packages again.

@bigbott
Copy link

bigbott commented Oct 6, 2024

dart pub global activate get_cli - fixed issue for me

@jakemac53
Copy link
Contributor

cc @sigurdm @jonasfj just for FYI, I am not sure if there is something reasonable for pub to do here or not.

Basically though, the case here is that the previous version solve for a globally activated package is no longer valid on the new SDK. Should globally activated packages re-validate their solve whenever the SDK is updated? I think that SDK constraints probably won't be respected in this case either?

@jonasfj
Copy link
Member

jonasfj commented Oct 7, 2024

Ah, yeah globally activated tools are an interesting use case... they probably do need to be re-activated to pick up versions that are compatible with the current SDK.

Yes, and no, people could have multiple SDKs installed.

I think today we actually delete the old snapshot and create a new snapshot.
So it's probably possible. But also kind of destructive, since a globally activated package has a pubspec.lock sitting somewhere in the PUB_CACHE and it's a bit surprising that dependencies can just magically upgrade on you.

I think, we do generally want to rethink globally activated packages, so that we just install a precompiled executable. It's less smart, there is no dart:mirrors, but installed things won't break left and right.
Anyways, it's not a thing that prioritized or in the pipeline anytime soon.

@jakemac53 jakemac53 transferred this issue from dart-lang/sdk Oct 7, 2024
@jakemac53
Copy link
Contributor

Transferred this to the pub repo because I do think that is the correct place for it, the packages can't do anything here.

Feel free to do with it as you please though, up to and including closing it as working as intended.

@sigurdm
Copy link
Contributor

sigurdm commented Oct 8, 2024

Yeah - we should do something here.

I'm assuming that the new analyzer version had valid constraints, and the global run failed to validate them.

edit: see next comment. This is probably not the way to go.

Currently the installed binstub does something equivalent to: dart path/to/snapshot skipping dartdev and not validating the pubspec.lock.

If it instead did something more like dart run the resolution could be validated and redone if no longer valid (eg. the sdk constraints are no longer satisfied).

It would cost a bit in startup time though. Maybe we should build something more specialized.

@sigurdm
Copy link
Contributor

sigurdm commented Oct 8, 2024

Thinking again we can do something simpler without sacrificing the fast path.

The sdk should recognize that the snapshot is not valid, and return a specific error code.
The binstub then invokes dart global run which is recompiling the snapshot.

dart global run could (and should) validate that the resolution is still good using the ensurePubspecResolved mechanism that dart run also uses.

@sigurdm
Copy link
Contributor

sigurdm commented Oct 8, 2024

Hmm .. seems we are already validating the sdk constraints:

lockFile.sdkConstraints.forEach((sdkName, constraint) {

Not sure what is going wrong here then.

@sigurdm
Copy link
Contributor

sigurdm commented Oct 8, 2024

I can reproduce this with:

$ flutter channel stable && flutter upgrade --force
[...]
$ flutter --version
Flutter 3.24.3 • channel stable • https://github.com/flutter/flutter
Framework • revision 2663184aa7 (4 weeks ago) • 2024-09-11 16:27:48 -0500
Engine • revision 36335019a8
Tools • Dart 3.5.3 • DevTools 2.37.3
$  flutter pub global activate intl_utils
[...]
Activated intl_utils 2.8.7.
$ cat ~/.pub-cache/global_packages/intl_utils/pubspec.lock 
[...]
sdks:
  dart: ">=3.4.0 <4.0.0"
$ flutter channel stable && flutter upgrade --force
[...]
$ flutter --version
Flutter 3.26.0-1.0.pre.397 • channel master • https://github.com/flutter/flutter
Framework • revision e695cd6e9a (2 hours ago) • 2024-10-08 10:41:09 +0200
Engine • revision 7e8011f3cc
Tools • Dart 3.6.0 (build 3.6.0-330.0.dev) • DevTools 2.40.0
$ flutter pub global run intl_utils:generate
Building package executable... (3.6s)
Failed to build intl_utils:generate:
../../.pub-cache/hosted/pub.dev/analyzer-6.8.0/lib/src/summary2/macro_declarations.dart:57:3: Error: The implicitly called unnamed constructor from 'ConstructorDeclarationImpl' has required parameters.

So it seems like checking the sdk constraint is not enough in this case.
We should do the complete ensureUpToDate, that would discover that we no longer have the right _macros package version (actually that would fail as soon as the dart sdk is new).

@jakemac53
Copy link
Contributor

Yeah, the issue isn't actually the SDK constraint it's the package:macros constraint, which ends up enforcing a certain SDK.

If this is an issue only created by SDK vendored packages, it might matter less.... although it might be an issue for flutter packages also?

@sigurdm sigurdm added the type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) label Oct 10, 2024
@sigurdm
Copy link
Contributor

sigurdm commented Oct 10, 2024

If this is an issue only created by SDK vendored packages, it might matter less.... although it might be an issue for flutter packages also?

Flutter packages cannot be global activated. So I believe the issue is currently mainly around package:_macros.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests