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

Getting warnings when depending on source_gen 1.0.3 #543

Closed
shilangyu opened this issue Jul 14, 2021 · 5 comments · Fixed by #544
Closed

Getting warnings when depending on source_gen 1.0.3 #543

shilangyu opened this issue Jul 14, 2021 · 5 comments · Fixed by #544

Comments

@shilangyu
Copy link

Running my code which depends on source_gen1.0.3 somewhere down the dep tree yields the following warning:

../../../../.pub-cache/hosted/pub.dartlang.org/source_gen-1.0.3/lib/src/utils.dart:46:39: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
  if (element.name != null && element.name!.isNotEmpty) {
                                      ^
../../../../.pub-cache/hosted/pub.dartlang.org/source_gen-1.0.3/lib/src/utils.dart:48:20: Warning: Operand of null-aware operation '!' has type 'String' which excludes null.
    return element.name!;

This warning did not appear prior to 1.0.3 (hence is probably related to the analyzer version bump). If any additional info is required I am happy to provide it.

Perhaps this is an analyzer bug and should be reported there, let me know. I just wish to not see warnings from outside of my code.

My dependency tree (please see raw, I am not sure how to retain newlines) Dart SDK 2.13.4 contracts_generator 0.0.1 |-- args 2.1.1 |-- build 2.0.3 | |-- analyzer 2.0.0 | | |-- _fe_analyzer_shared 23.0.0 | | | '-- meta... | | |-- cli_util 0.3.3 | | | |-- meta... | | | '-- path... | | |-- collection... | | |-- convert... | | |-- crypto... | | |-- glob... | | |-- meta... | | |-- package_config... | | |-- path... | | |-- pedantic... | | |-- pub_semver... | | |-- source_span... | | |-- watcher... | | '-- yaml... | |-- async 2.7.0 | | |-- collection... | | '-- meta... | |-- convert 3.0.1 | | '-- typed_data... | |-- crypto 3.0.1 | | |-- collection... | | '-- typed_data... | |-- glob 2.0.1 | | |-- async... | | |-- collection... | | |-- file 6.1.2 | | | |-- meta... | | | '-- path... | | |-- path... | | |-- pedantic... | | '-- string_scanner 1.1.0 | | |-- charcode 1.3.1 | | '-- source_span... | |-- logging 1.0.1 | |-- meta 1.7.0 | '-- path... |-- build_resolvers 2.0.4 | |-- analyzer... | |-- async... | |-- build... | |-- crypto... | |-- graphs 2.0.0 | |-- logging... | |-- package_config 2.0.0 | | '-- path... | |-- path... | |-- pool 1.5.0 | | |-- async... | | '-- stack_trace... | |-- pub_semver 2.0.0 | | '-- collection... | |-- stream_transform 2.0.0 | '-- yaml 3.1.0 | |-- collection... | |-- source_span... | '-- string_scanner... |-- build_runner_core 7.0.1 | |-- async... | |-- build... | |-- build_config 1.0.0 | | |-- checked_yaml 2.0.1 | | | |-- json_annotation... | | | |-- source_span... | | | '-- yaml... | | |-- json_annotation... | | |-- path... | | |-- pubspec_parse 1.0.0 | | | |-- checked_yaml... | | | |-- collection... | | | |-- json_annotation... | | | |-- pub_semver... | | | '-- yaml... | | '-- yaml... | |-- build_resolvers... | |-- collection 1.15.0 | |-- convert... | |-- crypto... | |-- glob... | |-- graphs... | |-- json_annotation 4.1.0 | | '-- meta... | |-- logging... | |-- meta... | |-- package_config... | |-- path... | |-- pedantic 1.11.1 | |-- pool... | |-- timing 1.0.0 | | '-- json_annotation... | |-- watcher 1.0.0 | | |-- async... | | |-- path... | | '-- pedantic... | '-- yaml... |-- build_test 2.1.2 | |-- async... | |-- build... | |-- build_config... | |-- build_resolvers... | |-- crypto... | |-- glob... | |-- html 0.15.0 | | |-- csslib 0.17.0 | | | '-- source_span... | | '-- source_span... | |-- logging... | |-- matcher 0.12.10 | | '-- stack_trace... | |-- package_config... | |-- path... | |-- pedantic... | |-- stream_transform... | |-- test... | |-- test_core 0.4.0 | | |-- analyzer... | | |-- args... | | |-- async... | | |-- boolean_selector... | | |-- collection... | | |-- coverage... | | |-- frontend_server_client 2.1.0 | | | |-- async... | | | '-- path... | | |-- glob... | | |-- io... | | |-- matcher... | | |-- meta... | | |-- package_config... | | |-- path... | | |-- pedantic... | | |-- pool... | | |-- source_map_stack_trace 2.1.0 | | | |-- path... | | | |-- source_maps... | | | '-- stack_trace... | | |-- source_maps 0.10.10 | | | '-- source_span... | | |-- source_span... | | |-- stack_trace... | | |-- stream_channel... | | |-- test_api... | | |-- vm_service 7.1.0 | | '-- yaml... | '-- watcher... |-- code_builder 4.0.0 | |-- built_collection 5.1.0 | |-- built_value 8.1.1 | | |-- built_collection... | | |-- collection... | | |-- fixnum... | | '-- meta... | |-- collection... | |-- matcher... | '-- meta... |-- cqrs 6.0.0 | '-- http 0.13.3 | |-- async... | |-- http_parser 4.0.0 | | |-- charcode... | | |-- collection... | | |-- source_span... | | |-- string_scanner... | | '-- typed_data... | |-- meta... | |-- path... | '-- pedantic... |-- dart_style 2.0.2 | |-- analyzer... | |-- args... | |-- path... | |-- pub_semver... | '-- source_span 1.8.1 | |-- collection... | |-- path... | '-- term_glyph 1.2.0 |-- equatable 2.0.3 | |-- collection... | '-- meta... |-- fixnum 1.0.0 |-- json_serializable 5.0.0 | |-- analyzer... | |-- build... | |-- build_config... | |-- collection... | |-- json_annotation... | |-- meta... | |-- path... | |-- source_gen 1.0.3 | | |-- analyzer... | | |-- async... | | |-- build... | | |-- dart_style... | | |-- glob... | | |-- meta... | | |-- path... | | |-- pedantic... | | |-- source_span... | | '-- yaml... | '-- source_helper 1.2.0 | |-- analyzer... | |-- collection... | '-- source_gen... |-- lint 1.5.3 |-- path 1.8.0 |-- protobuf 2.0.0 | '-- fixnum... |-- recase 4.0.0 '-- test 1.17.10 |-- analyzer... |-- async... |-- boolean_selector 2.1.0 | |-- source_span... | '-- string_scanner... |-- collection... |-- coverage 1.0.3 | |-- args... | |-- logging... | |-- package_config... | |-- path... | |-- source_maps... | |-- stack_trace... | '-- vm_service... |-- http_multi_server 3.0.1 | '-- async... |-- io 1.0.3 | |-- meta... | |-- path... | '-- string_scanner... |-- js 0.6.3 |-- node_preamble 2.0.1 |-- package_config... |-- path... |-- pedantic... |-- pool... |-- shelf 1.2.0 | |-- async... | |-- collection... | |-- http_parser... | |-- path... | |-- stack_trace... | '-- stream_channel... |-- shelf_packages_handler 3.0.0 | |-- path... | |-- shelf... | '-- shelf_static... |-- shelf_static 1.1.0 | |-- convert... | |-- http_parser... | |-- mime 1.0.0 | |-- path... | '-- shelf... |-- shelf_web_socket 1.0.1 | |-- shelf... | |-- stream_channel... | '-- web_socket_channel... |-- source_span... |-- stack_trace 1.10.0 | '-- path... |-- stream_channel 2.1.0 | '-- async... |-- test_api 0.4.2 | |-- async... | |-- boolean_selector... | |-- collection... | |-- matcher... | |-- meta... | |-- source_span... | |-- stack_trace... | |-- stream_channel... | |-- string_scanner... | '-- term_glyph... |-- test_core... |-- typed_data 1.3.0 | '-- collection... |-- web_socket_channel 2.1.0 | |-- async... | |-- crypto... | '-- stream_channel... |-- webkit_inspection_protocol 1.0.0 | '-- logging... '-- yaml...
@jakemac53
Copy link
Contributor

This definitely looks like a bug, we should have required the latest analyzer and removed the !.

@jakemac53
Copy link
Contributor

cc @scheglov (I have a fix out though)

@scheglov
Copy link
Contributor

AFAIK this is not a bug.
Making something nullable into non-nullable is usually not a breaking change.
So, code works.
But the language requires a warning.
There was some discussion about warnings during compilation and execution, cannot find it.

Making a clean up to avoid the warning is good of course.

@jakemac53
Copy link
Contributor

In general we want to avoid triggering any warnings - although I agree the code is not broken. But it does appear broken to some users of the code, and the general expectation is that we don't introduce compile time warnings for our users.

@natebosch
Copy link
Member

There is some discussion about suppressing these warnings so that end users won't see them in these situations.

See dart-lang/sdk#34137 and dart-lang/sdk#46264

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.

4 participants