dart-lang / sdk

The Dart SDK, including the VM, JS and Wasm compilers, analysis, core libraries, and more.
https://dart.dev
BSD 3-Clause "New" or "Revised" License
10.28k stars 1.59k forks source link

Catch private types referenced from public APIs #57979

Open Hixie opened 5 years ago

Hixie commented 5 years ago

A publicly-accessible method with an argument whose type is private, or a publicly-accessible field with a type that is private, or a method with a return value that is private, or similarly with getters/setters or other such things, should be flagged by the linter.

See also dart-lang/sdk#57951.

Hixie commented 5 years ago

For example, WidgetInspectorService.initServiceExtensions has an argument whose type is private, which makes no sense.

pq commented 5 years ago

WidgetInspectorService.initServiceExtensions

fyi @jacob314

bwilkerson commented 5 years ago

I have a significant start at this. I've wanted it for the analyzer API for a long time, so I started implementing it last fall. Then I got busy and never returned to it. Nevertheless, a significant portion of the work has been done if someone wants to finish it.

pq commented 5 years ago

Fantastic! Maybe push it up on a branch in case anyone wants to jump?

bwilkerson commented 3 years ago

I dusted off the code that I have and updated it a bit. The question that I have is exactly what this lint should catch.

It seems fairly obvious to me that we want to flag when a private type is used as either a return type or parameter type for a public function/method (including getters and setters induced by a public field). But do we want to also flag private types being used as a supertype of a public type? How about as the bounds of a type parameter on a public class or function?