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

dart analyze <file> says the file is fine, dart <file> fails with compile-time error #49811

Closed
osa1 opened this issue Aug 25, 2022 · 2 comments
Closed
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@osa1
Copy link
Member

osa1 commented Aug 25, 2022

Tried with the current HEAD (3669086).

Repro:

  1. git clone https://github.com/osa1/protobuf.dart -b analyzer_bug
  2. cd protobuf.dart/protobuf
  3. dart pub get
  4. dart analyze test/coded_buffer_reader_test.dart
  5. dart test/coded_buffer_reader_test.dart

Step 4 says "No issues found!", but step 5 fails with compile-time error:

lib/src/protobuf/pb_list.dart:218:31: Error: The method 'deepCopy' isn't defined for the class 'GeneratedMessage'.
 - 'GeneratedMessage' is from 'package:protobuf/protobuf.dart' ('lib/protobuf.dart').
Try correcting the name to the name of an existing method, or defining a method named 'deepCopy'.
        wrappedList.add(value.deepCopy(freeze: freeze) as dynamic);
                              ^^^^^^^^
lib/src/protobuf/pb_map.dart:138:33: Error: The method 'deepCopy' isn't defined for the class 'GeneratedMessage'.
 - 'GeneratedMessage' is from 'package:protobuf/protobuf.dart' ('lib/protobuf.dart').
Try correcting the name to the name of an existing method, or defining a method named 'deepCopy'.
        wrappedMap[key] = value.deepCopy(freeze: freeze) as dynamic;
                                ^^^^^^^^
@osa1
Copy link
Member Author

osa1 commented Aug 25, 2022

We discussed this at the office and @eernstg explained that the CFE error is valid. My understanding of the problem is:

  • We have value : E
  • We promote it with value is GeneratedMessage
  • The resulting type is an intersection type of E and GeneratedMessage
  • Intersection types are not reified
  • Because the type is not reified, the extension bound T extends GeneratedMessage does not hold for this type
  • So we can't call the extension methods

So the error is valid, and analyzer should've caught it.

@bwilkerson bwilkerson added the area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. label Aug 25, 2022
@srawlins srawlins added P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) analyzer-spec Issues with the analyzer's implementation of the language spec labels Aug 26, 2022
@srawlins
Copy link
Member

srawlins commented Jun 7, 2024

Still reproducible today. But there is a duplicate issue that is more active. Tracking as #53711.

@srawlins srawlins closed this as completed Jun 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-spec Issues with the analyzer's implementation of the language spec area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P3 A lower priority bug or feature request type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants