[sdk] Mark dart:developer APIs with since information

Without the since information added, packages can use these APIs despite their SDK constraints potentially allowing SDK versions without them. For example, in package:leak_tracker recently: https://github.com/dart-lang/leak_tracker/issues/201.

I only added Since information to APIs added since Dart 2.12 since that's the lowest relevant SDK constraint with sound null safety.

TEST=ci

Cq-Include-Trybots: luci.dart.try:flutter-analyze-try
CoreLibraryReviewExempt: This CL does not change any APIs or their implementation, only adding relevant Since documentation to support correct triggering of the sdk_version_since diagnostic.
Change-Id: I27613ebf745f084a3056b8ffd2542221d939a838
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/346200
Commit-Queue: Derek Xu <derekx@google.com>
Reviewed-by: Derek Xu <derekx@google.com>
Auto-Submit: Parker Lougheed <parlough@gmail.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
This commit is contained in:
Parker Lougheed 2024-01-22 14:58:12 +00:00 committed by Commit Queue
parent 46853586f1
commit eb5c77e7c2
4 changed files with 9 additions and 2 deletions

View file

@ -327,7 +327,7 @@ namespace dart {
V(_Utf8Decoder, _scan, Utf8DecoderScan, 0xb98ea6c2) \
V(_FutureListener, handleValue, FutureListenerHandleValue, 0xec1745d2) \
V(::, get:has63BitSmis, Has63BitSmis, 0xf60ccb11) \
V(::, get:extensionStreamHasListener, ExtensionStreamHasListener, 0xfaa5db24)\
V(::, get:extensionStreamHasListener, ExtensionStreamHasListener, 0xfaa5dee5)\
V(_Smi, get:hashCode, Smi_hashCode, 0x75d240f2) \
V(_Mint, get:hashCode, Mint_hashCode, 0x75d240f2) \
V(_Double, get:hashCode, Double_hashCode, 0x75d244b3) \

View file

@ -139,9 +139,11 @@ external void log(
///
/// NOTE: There are no guarantees of forward progress. An implementation may
/// return the same value forever for this barrier state.
@Since('2.19')
external int get reachabilityBarrier;
/// Functionality available on the native runtime.
@Since('3.0')
abstract final class NativeRuntime {
/// The build ID for the running application.
///
@ -153,6 +155,7 @@ abstract final class NativeRuntime {
///
/// The build ID is only available for ahead-of-time compiled programs. If a
/// build ID is not available, the value is `null`.
@Since('3.1')
external static String? get buildId;
/// Writes a snapshot of the heap to [filepath].

View file

@ -142,6 +142,7 @@ void registerExtension(String method, ServiceExtensionHandler handler) {
@pragma("vm:recognized", "other")
@pragma("vm:prefer-inline")
@pragma("vm:idempotent")
@Since('2.18')
external bool get extensionStreamHasListener;
/// Post an event of [eventKind] with payload of [eventData] to the "Extension"
@ -151,7 +152,8 @@ external bool get extensionStreamHasListener;
/// Override [stream] to set the destination stream that the event should be
/// posted to. The [stream] may not start with an underscore or be a core VM
/// Service stream.
void postEvent(String eventKind, Map eventData, {String stream = 'Extension'}) {
void postEvent(String eventKind, Map eventData,
{@Since('3.0 ') String stream = 'Extension'}) {
const destinationStreamKey = '__destinationStream';
// Keep protected streams in sync with `streams_` in runtime/vm/service.cc
// `Extension` is the only stream that should not be protected here.

View file

@ -23,6 +23,7 @@ final class ServiceProtocolInfo {
/// The Uri to connect to the service via web socket. If the web server is
/// not running, this will be null.
@Since('2.14')
Uri? get serverWebSocketUri {
Uri? uri = serverUri;
if (uri != null) {
@ -124,6 +125,7 @@ final class Service {
///
/// Returns null if the running Dart environment does not support the service
/// protocol.
@Since('3.2')
static String? getObjectId(Object object) {
return _getObjectId(object);
}