mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
[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:
parent
78f95a427b
commit
770c9d77c5
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
25
tests/web/regress/issue/49898_test.dart
Normal file
25
tests/web/regress/issue/49898_test.dart
Normal 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);
|
||||
}
|
||||
}
|
25
tests/web_2/regress/issue/49898_test.dart
Normal file
25
tests/web_2/regress/issue/49898_test.dart
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue