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

Mockito only supports analyzer >=5.12.0, but pubspec specifies >=5.11.0 #656

Closed
rrousselGit opened this issue Jun 16, 2023 · 2 comments
Closed

Comments

@rrousselGit
Copy link

Currently, mockito relies on analyzer.InvalidType, which was introduced as part of 5.12.0.
As such, it is currently incompatible with analyzer 5.11.0, yet the pubspec says otherwise.

This causes dart pub downgrade to possibly resolve with analyzer 5.11.0, which would fail to compile.

rrousselGit added a commit to rrousselGit/mockito that referenced this issue Jun 16, 2023
@fwemaere
Copy link

fwemaere commented Jun 22, 2023

Il have same bug with mockito 5.4.2 and analyzer 5.12

[WARNING] ../../../../.pub-cache/hosted/pub.dev/mockito-5.4.2/lib/src/builder.dart:1475:45: Error: 'InvalidType' isn't a type.
      if (type.isBottom || type is analyzer.InvalidType) {
                                            ^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/mockito-5.4.2/lib/src/builder.dart:2096:26: Error: 'InvalidType' isn't a type.
    if (type is analyzer.InvalidType) {
                         ^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/mockito-5.4.2/lib/src/builder.dart:2298:33: Error: 'InvalidType' isn't a type.
    } else if (self is analyzer.InvalidType) {
                                ^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/mockito-5.4.2/lib/src/builder.dart:2395:31: Error: The getter 'importPrefix' isn't defined for the class 'NamedType'.
 - 'NamedType' is from 'package:analyzer/dart/ast/ast.dart' ('../../../../.pub-cache/hosted/pub.dev/analyzer-5.11.1/lib/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'importPrefix'.
    final importPrefix = this.importPrefix;
                              ^^^^^^^^^^^^
../../../../.pub-cache/hosted/pub.dev/mockito-5.4.2/lib/src/builder.dart:2397:45: Error: The getter 'name2' isn't defined for the class 'NamedType'.
 - 'NamedType' is from 'package:analyzer/dart/ast/ast.dart' ('../../../../.pub-cache/hosted/pub.dev/analyzer-5.11.1/lib/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'name2'.
      return '${importPrefix.name.lexeme}.${name2.lexeme}';
                                            ^^^^^
../../../../.pub-cache/hosted/pub.dev/mockito-5.4.2/lib/src/builder.dart:2399:12: Error: The getter 'name2' isn't defined for the class 'NamedType'.
 - 'NamedType' is from 'package:analyzer/dart/ast/ast.dart' ('../../../../.pub-cache/hosted/pub.dev/analyzer-5.11.1/lib/dart/ast/ast.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'name2'.
    return name2.lexeme;
           ^^^^^

it seems to be only compatible with analyzer >=5.13.0

@yanok
Copy link
Contributor

yanok commented Jun 30, 2023

Thanks for reporting. I wonder why CI didn't catch it. I guess it never tries to dart pub downgrade.

Probably we should add it..

copybara-service bot pushed a commit that referenced this issue Jun 30, 2023
There was a recent change that added usage of the new `InvalidType` to
Mockito codegen, but it only appears in analyzer 5.12.

Fixes #656

PiperOrigin-RevId: 544601698
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants