Files
sdk/tests/lib/js/operator_static_test.dart
T
Srujan Gaddam 7f8611c9a6 [dart:js_interop] Disallow external operators using static interop
We've disallowed operators for interop methods before, but haven't
applied that to extension and inline methods. We currently support []
and []= using static interop, but that may or may not change later.

Change-Id: I0e52c29f1e47c1354182d2bd5cafbac30e314d11
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/301723
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Joshua Litt <joshualitt@google.com>
Commit-Queue: Srujan Gaddam <srujzs@google.com>
2023-05-22 21:50:51 +00:00

142 lines
7.5 KiB
Dart

// Copyright (c) 2023, 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.
@JS()
library operator_test;
import 'package:js/js.dart';
@JS()
class JSClass {
// https://dart.dev/guides/language/language-tour#_operators for the list of
// operators allowed by the language.
external void operator <(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator <=(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >=(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator -(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator +(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator /(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator ~/(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator *(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator %(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator |(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator ^(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator &(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator <<(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >>(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >>>(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator [](_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator []=(_, __);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator ~();
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external bool operator ==(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
}
@JS()
@anonymous
class AnonymousClass {
external void operator <(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator <=(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >=(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator -(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator +(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator /(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator ~/(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator *(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator %(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator |(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator ^(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator &(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator <<(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >>(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator >>>(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator [](_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator []=(_, __);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external void operator ~();
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
external bool operator ==(_);
// ^
// [web] JS interop classes do not support operator methods, with the exception of '[]' and '[]=' using static interop.
}
void main() {}