[typed_data] Fix breakage introduced in recent change.

This fixes a regression introduced by
https://dart-review.googlesource.com/c/sdk/+/254501. The change
accidentally excluded some  clauses. This was not detected by the
CFE (it should be a static error), and as a result unsound
optimizations were made by dart2js.

Fixes https://dart-review.googlesource.com/c/sdk/+/254501

Change-Id: Iff52cba277546f2a9fab3c2c2736410d272dad7e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/264601
Reviewed-by: Stephen Adams <sra@google.com>
Commit-Queue: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
Sigmund Cherem 2022-10-18 01:16:27 +00:00 committed by Commit Queue
parent 78f95a427b
commit 770c9d77c5
4 changed files with 56 additions and 4 deletions

View file

@ -194,7 +194,8 @@ class Float64x2 {
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableByteBufferView.
class _UnmodifiableByteBufferView implements ByteBuffer {
class _UnmodifiableByteBufferView
implements ByteBuffer, UnmodifiableByteBufferView {
final ByteBuffer _data;
_UnmodifiableByteBufferView(ByteBuffer data) : _data = data;
@ -257,7 +258,7 @@ class _UnmodifiableByteBufferView implements ByteBuffer {
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableByteDataView.
class _UnmodifiableByteDataView implements ByteData {
class _UnmodifiableByteDataView implements ByteData, UnmodifiableByteDataView {
final ByteData _data;
_UnmodifiableByteDataView(ByteData data) : _data = data;

View file

@ -194,7 +194,8 @@ class Float64x2 {
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableByteBufferView.
class _UnmodifiableByteBufferView implements ByteBuffer {
class _UnmodifiableByteBufferView
implements ByteBuffer, UnmodifiableByteBufferView {
final ByteBuffer _data;
_UnmodifiableByteBufferView(ByteBuffer data) : _data = data;
@ -257,7 +258,7 @@ class _UnmodifiableByteBufferView implements ByteBuffer {
///
/// It is a compile-time error for a class to attempt to extend or implement
/// UnmodifiableByteDataView.
class _UnmodifiableByteDataView implements ByteData {
class _UnmodifiableByteDataView implements ByteData, UnmodifiableByteDataView {
final ByteData _data;
_UnmodifiableByteDataView(ByteData data) : _data = data;

View file

@ -0,0 +1,25 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// This is a regression test for https://github.com/dart-lang/sdk/issues/49898,
/// but ideally we should have a better test that is more general. For example,
/// a test that ensures all patch files also have the same static errors
/// provided as regular sources (the source of the regression is statically
/// detectable).
import 'dart:typed_data';
void main() {
final a = A(ByteData(10)..setUint16(0, 42));
print('Number in ByteData: ${a.getUint16()}');
}
class A {
final UnmodifiableByteDataView bytes;
A(ByteData bytes) : bytes = UnmodifiableByteDataView(bytes);
int getUint16() {
return bytes.getUint16(0);
}
}

View file

@ -0,0 +1,25 @@
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/// This is a regression test for https://github.com/dart-lang/sdk/issues/49898,
/// but ideally we should have a better test that is more general. For example,
/// a test that ensures all patch files also have the same static errors
/// provided as regular sources (the source of the regression is statically
/// detectable).
import 'dart:typed_data';
void main() {
final a = A(ByteData(10)..setUint16(0, 42));
print('Number in ByteData: ${a.getUint16()}');
}
class A {
final UnmodifiableByteDataView bytes;
A(ByteData bytes) : bytes = UnmodifiableByteDataView(bytes);
int getUint16() {
return bytes.getUint16(0);
}
}