mirror of
https://github.com/dart-lang/sdk
synced 2024-10-01 19:14:49 +00:00
[dart:js_interop] Disallow user @staticInterop classes from subtyping most dart:_js_types types
Since user @staticInterop types are erased to JavaScriptObject, they should only be able to subtype other types that are :> JavaScriptObject, which are just JSObject and JSAny. Eventually all the other JS types will move to extension types and we can remove this check. Change-Id: If56b6770e141238b583937880ca87496780c8fac Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/316865 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Srujan Gaddam <srujzs@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
1bae1b3dd5
commit
86eb49ac19
|
@ -21,6 +21,10 @@
|
|||
`dart:js_interop` types like `JSNumber` when used in an external API. This
|
||||
only affects `dart:js_interop` classes and not `package:js` or other forms of
|
||||
JS interop.
|
||||
- **Subtyping `dart:js_interop` types**:
|
||||
`@staticInterop` types can subtype only `JSObject` and `JSAny` from the set of
|
||||
JS types in `dart:js_interop`. Subtyping other types from `dart:js_interop`
|
||||
would result in confusing type errors before, so this makes it a static error.
|
||||
|
||||
## 3.1.0
|
||||
|
||||
|
|
|
@ -8454,6 +8454,38 @@ Message _withArgumentsJsInteropStaticInteropWithInstanceMembers(String name) {
|
|||
arguments: {'name': name});
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Template<Message Function(String name, String name2)>
|
||||
templateJsInteropStaticInteropWithInvalidJsTypesSupertype =
|
||||
const Template<Message Function(String name, String name2)>(
|
||||
problemMessageTemplate:
|
||||
r"""`@staticInterop` class '#name' cannot have '#name2' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.""",
|
||||
correctionMessageTemplate:
|
||||
r"""Try subtyping `JSObject` or `JSAny` instead, or try casting an object of type '#name' to '#name2' when needed.""",
|
||||
withArguments:
|
||||
_withArgumentsJsInteropStaticInteropWithInvalidJsTypesSupertype);
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Message Function(String name, String name2)>
|
||||
codeJsInteropStaticInteropWithInvalidJsTypesSupertype =
|
||||
const Code<Message Function(String name, String name2)>(
|
||||
"JsInteropStaticInteropWithInvalidJsTypesSupertype",
|
||||
);
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
Message _withArgumentsJsInteropStaticInteropWithInvalidJsTypesSupertype(
|
||||
String name, String name2) {
|
||||
if (name.isEmpty) throw 'No name provided';
|
||||
name = demangleMixinApplicationName(name);
|
||||
if (name2.isEmpty) throw 'No name provided';
|
||||
name2 = demangleMixinApplicationName(name2);
|
||||
return new Message(codeJsInteropStaticInteropWithInvalidJsTypesSupertype,
|
||||
problemMessage:
|
||||
"""`@staticInterop` class '${name}' cannot have '${name2}' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.""",
|
||||
correctionMessage: """Try subtyping `JSObject` or `JSAny` instead, or try casting an object of type '${name}' to '${name2}' when needed.""",
|
||||
arguments: {'name': name, 'name2': name2});
|
||||
}
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Template<Message Function(String name, String name2)>
|
||||
templateJsInteropStaticInteropWithNonStaticSupertype =
|
||||
|
|
|
@ -31,6 +31,7 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
|
|||
templateJsInteropNonStaticWithStaticInteropSupertype,
|
||||
templateJsInteropStaticInteropNoJSAnnotation,
|
||||
templateJsInteropStaticInteropWithInstanceMembers,
|
||||
templateJsInteropStaticInteropWithInvalidJsTypesSupertype,
|
||||
templateJsInteropStaticInteropWithNonStaticSupertype,
|
||||
templateJsInteropObjectLiteralConstructorPositionalParameters,
|
||||
templateJsInteropNativeClassInAnnotation,
|
||||
|
@ -247,17 +248,13 @@ class JsInteropChecks extends RecursiveVisitor {
|
|||
report(templateJsInteropStaticInteropNoJSAnnotation
|
||||
.withArguments(node.name));
|
||||
}
|
||||
if (superclass != null && !hasStaticInteropAnnotation(superclass)) {
|
||||
report(templateJsInteropStaticInteropWithNonStaticSupertype
|
||||
.withArguments(node.name, superclass.name));
|
||||
if (superclass != null) {
|
||||
_checkSuperclassOfStaticInteropClass(node, superclass);
|
||||
}
|
||||
// Validate that superinterfaces are all annotated as static as well. Note
|
||||
// Validate that superinterfaces are all valid supertypes as well. Note
|
||||
// that mixins are already disallowed and therefore are not checked here.
|
||||
for (final supertype in node.implementedTypes) {
|
||||
if (!hasStaticInteropAnnotation(supertype.classNode)) {
|
||||
report(templateJsInteropStaticInteropWithNonStaticSupertype
|
||||
.withArguments(node.name, supertype.classNode.name));
|
||||
}
|
||||
_checkSuperclassOfStaticInteropClass(node, supertype.classNode);
|
||||
}
|
||||
} else {
|
||||
// For non-inline classes, `dart:js_interop`'s `@JS` can only be used
|
||||
|
@ -857,6 +854,39 @@ class JsInteropChecks extends RecursiveVisitor {
|
|||
}
|
||||
}
|
||||
|
||||
/// Reports an error if @staticInterop classes extends or implements a
|
||||
/// non-@staticInterop type or an invalid dart:_js_types type.
|
||||
void _checkSuperclassOfStaticInteropClass(Class node, Class superclass) {
|
||||
void report(Message message) => _reporter.report(
|
||||
message, node.fileOffset, node.name.length, node.fileUri);
|
||||
if (!hasStaticInteropAnnotation(superclass)) {
|
||||
report(templateJsInteropStaticInteropWithNonStaticSupertype.withArguments(
|
||||
node.name, superclass.name));
|
||||
} else {
|
||||
// dart:_js_types @staticInterop types are special. They are custom-erased
|
||||
// to different types at runtime. User @staticInterop types are always
|
||||
// erased to JavaScriptObject. As such, this means that we should only
|
||||
// allow users to subtype dart:_js_types types that erase to a
|
||||
// T >: JavaScriptObject. Currently, this is only JSObject and JSAny.
|
||||
// TODO(srujzs): This error should be temporary. In the future, once we
|
||||
// have extension types that can implement concrete classes, we can move
|
||||
// all the dart:_js_types that aren't JSObject and JSAny to extension
|
||||
// types. Then, this error becomes redundant. This would also allow us to
|
||||
// idiomatically add type parameters to JSArray and JSPromise.
|
||||
final superclassUri = superclass.enclosingLibrary.importUri;
|
||||
// Make an exception for some internal libraries.
|
||||
final allowList = {'_js_types', '_js_helper'};
|
||||
if (superclassUri.isScheme('dart') &&
|
||||
superclassUri.path == '_js_types' &&
|
||||
!allowList.contains(node.enclosingLibrary.importUri.path) &&
|
||||
superclass.name != 'JSAny' &&
|
||||
superclass.name != 'JSObject') {
|
||||
report(templateJsInteropStaticInteropWithInvalidJsTypesSupertype
|
||||
.withArguments(node.name, superclass.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If [procedure] is a generated procedure that represents a relevant
|
||||
/// tear-off, return the torn-off member.
|
||||
///
|
||||
|
|
|
@ -646,6 +646,8 @@ JsInteropStaticInteropTrustTypesUsedWithoutStaticInterop/analyzerCode: Fail # We
|
|||
JsInteropStaticInteropTrustTypesUsedWithoutStaticInterop/example: Fail # Web compiler specific
|
||||
JsInteropStaticInteropWithInstanceMembers/analyzerCode: Fail # Web compiler specific
|
||||
JsInteropStaticInteropWithInstanceMembers/example: Fail # Web compiler specific
|
||||
JsInteropStaticInteropWithInvalidJsTypesSupertype/analyzerCode: Fail # Web compiler specific
|
||||
JsInteropStaticInteropWithInvalidJsTypesSupertype/example: Fail # Web compiler specific
|
||||
JsInteropStaticInteropWithNonStaticSupertype/analyzerCode: Fail # Web compiler specific
|
||||
JsInteropStaticInteropWithNonStaticSupertype/example: Fail # Web compiler specific
|
||||
JsInteropFunctionToJSRequiresStaticType/analyzerCode: Fail # Web compiler specific
|
||||
|
|
|
@ -5630,6 +5630,10 @@ JsInteropStaticInteropWithInstanceMembers:
|
|||
problemMessage: "JS interop class '#name' with `@staticInterop` annotation cannot declare instance members."
|
||||
correctionMessage: "Try moving the instance member to a static extension."
|
||||
|
||||
JsInteropStaticInteropWithInvalidJsTypesSupertype:
|
||||
problemMessage: "`@staticInterop` class '#name' cannot have '#name2' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes."
|
||||
correctionMessage: "Try subtyping `JSObject` or `JSAny` instead, or try casting an object of type '#name' to '#name2' when needed."
|
||||
|
||||
JsInteropStaticInteropWithNonStaticSupertype:
|
||||
problemMessage: "JS interop class '#name' has an `@staticInterop` annotation, but has supertype '#name2', which does not."
|
||||
correctionMessage: "Try marking the supertype as a static interop class using `@staticInterop`."
|
||||
|
|
|
@ -62,7 +62,9 @@ interop
|
|||
intervening
|
||||
irrefutable
|
||||
js_util
|
||||
jsany
|
||||
jsexport
|
||||
jsobject
|
||||
libraries.json
|
||||
list.filled
|
||||
loadlibrary
|
||||
|
|
|
@ -0,0 +1,268 @@
|
|||
// 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 subtype_js_types_static_test;
|
||||
|
||||
import 'dart:js_interop';
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSAny extends JSAny {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSAny implements JSAny {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSObject extends JSObject {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSObject implements JSObject {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSFunction extends JSFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSFunction' cannot have 'JSFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSFunction implements JSFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSFunction' cannot have 'JSFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSExportedDartFunction extends JSExportedDartFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSExportedDartFunction' cannot have 'JSExportedDartFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSExportedDartFunction implements JSExportedDartFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSExportedDartFunction' cannot have 'JSExportedDartFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSArray extends JSArray {
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSArray' cannot have 'JSArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
// Silence error about extending class with only factories.
|
||||
external factory ExtendsJSArray();
|
||||
}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSArray implements JSArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSArray' cannot have 'JSArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSBoxedDartObject extends JSBoxedDartObject {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSBoxedDartObject' cannot have 'JSBoxedDartObject' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSBoxedDartObject implements JSBoxedDartObject {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSBoxedDartObject' cannot have 'JSBoxedDartObject' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSArrayBuffer extends JSArrayBuffer {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSArrayBuffer' cannot have 'JSArrayBuffer' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSArrayBuffer implements JSArrayBuffer {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSArrayBuffer' cannot have 'JSArrayBuffer' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSDataView extends JSDataView {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSDataView' cannot have 'JSDataView' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSDataView implements JSDataView {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSDataView' cannot have 'JSDataView' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSTypedArray extends JSTypedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSTypedArray' cannot have 'JSTypedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSTypedArray implements JSTypedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSTypedArray' cannot have 'JSTypedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSInt8Array extends JSInt8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSInt8Array' cannot have 'JSInt8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSInt8Array implements JSInt8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSInt8Array' cannot have 'JSInt8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint8Array extends JSUint8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint8Array' cannot have 'JSUint8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint8Array implements JSUint8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint8Array' cannot have 'JSUint8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint8ClampedArray extends JSUint8ClampedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint8ClampedArray' cannot have 'JSUint8ClampedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint8ClampedArray implements JSUint8ClampedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint8ClampedArray' cannot have 'JSUint8ClampedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSInt16Array extends JSInt16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSInt16Array' cannot have 'JSInt16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSInt16Array implements JSInt16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSInt16Array' cannot have 'JSInt16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint16Array extends JSUint16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint16Array' cannot have 'JSUint16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint16Array implements JSUint16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint16Array' cannot have 'JSUint16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSInt32Array extends JSInt32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSInt32Array' cannot have 'JSInt32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSInt32Array implements JSInt32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSInt32Array' cannot have 'JSInt32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint32Array extends JSUint32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint32Array' cannot have 'JSUint32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint32Array implements JSUint32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint32Array' cannot have 'JSUint32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSFloat32Array extends JSFloat32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSFloat32Array' cannot have 'JSFloat32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSFloat32Array implements JSFloat32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSFloat32Array' cannot have 'JSFloat32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSFloat64Array extends JSFloat64Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSFloat64Array' cannot have 'JSFloat64Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSFloat64Array implements JSFloat64Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSFloat64Array' cannot have 'JSFloat64Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSNumber extends JSNumber {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSNumber' cannot have 'JSNumber' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSNumber implements JSNumber {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSNumber' cannot have 'JSNumber' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSBoolean extends JSBoolean {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSBoolean' cannot have 'JSBoolean' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSBoolean implements JSBoolean {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSBoolean' cannot have 'JSBoolean' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSString extends JSString {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSString' cannot have 'JSString' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSString implements JSString {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSString' cannot have 'JSString' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSPromise extends JSPromise {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSPromise' cannot have 'JSPromise' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSPromise implements JSPromise {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSPromise' cannot have 'JSPromise' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
|
@ -0,0 +1,268 @@
|
|||
// 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 subtype_js_types_static_test;
|
||||
|
||||
import 'dart:js_interop';
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSAny extends JSAny {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSAny implements JSAny {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSObject extends JSObject {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSObject implements JSObject {}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSFunction extends JSFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSFunction' cannot have 'JSFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSFunction implements JSFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSFunction' cannot have 'JSFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSExportedDartFunction extends JSExportedDartFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSExportedDartFunction' cannot have 'JSExportedDartFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSExportedDartFunction implements JSExportedDartFunction {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSExportedDartFunction' cannot have 'JSExportedDartFunction' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSArray extends JSArray {
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSArray' cannot have 'JSArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
// Silence error about extending class with only factories.
|
||||
external factory ExtendsJSArray();
|
||||
}
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSArray implements JSArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSArray' cannot have 'JSArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSBoxedDartObject extends JSBoxedDartObject {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSBoxedDartObject' cannot have 'JSBoxedDartObject' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSBoxedDartObject implements JSBoxedDartObject {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSBoxedDartObject' cannot have 'JSBoxedDartObject' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSArrayBuffer extends JSArrayBuffer {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSArrayBuffer' cannot have 'JSArrayBuffer' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSArrayBuffer implements JSArrayBuffer {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSArrayBuffer' cannot have 'JSArrayBuffer' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSDataView extends JSDataView {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSDataView' cannot have 'JSDataView' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSDataView implements JSDataView {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSDataView' cannot have 'JSDataView' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSTypedArray extends JSTypedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSTypedArray' cannot have 'JSTypedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSTypedArray implements JSTypedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSTypedArray' cannot have 'JSTypedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSInt8Array extends JSInt8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSInt8Array' cannot have 'JSInt8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSInt8Array implements JSInt8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSInt8Array' cannot have 'JSInt8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint8Array extends JSUint8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint8Array' cannot have 'JSUint8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint8Array implements JSUint8Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint8Array' cannot have 'JSUint8Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint8ClampedArray extends JSUint8ClampedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint8ClampedArray' cannot have 'JSUint8ClampedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint8ClampedArray implements JSUint8ClampedArray {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint8ClampedArray' cannot have 'JSUint8ClampedArray' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSInt16Array extends JSInt16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSInt16Array' cannot have 'JSInt16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSInt16Array implements JSInt16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSInt16Array' cannot have 'JSInt16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint16Array extends JSUint16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint16Array' cannot have 'JSUint16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint16Array implements JSUint16Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint16Array' cannot have 'JSUint16Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSInt32Array extends JSInt32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSInt32Array' cannot have 'JSInt32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSInt32Array implements JSInt32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSInt32Array' cannot have 'JSInt32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSUint32Array extends JSUint32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSUint32Array' cannot have 'JSUint32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSUint32Array implements JSUint32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSUint32Array' cannot have 'JSUint32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSFloat32Array extends JSFloat32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSFloat32Array' cannot have 'JSFloat32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSFloat32Array implements JSFloat32Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSFloat32Array' cannot have 'JSFloat32Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSFloat64Array extends JSFloat64Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSFloat64Array' cannot have 'JSFloat64Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSFloat64Array implements JSFloat64Array {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSFloat64Array' cannot have 'JSFloat64Array' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSNumber extends JSNumber {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSNumber' cannot have 'JSNumber' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSNumber implements JSNumber {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSNumber' cannot have 'JSNumber' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSBoolean extends JSBoolean {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSBoolean' cannot have 'JSBoolean' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSBoolean implements JSBoolean {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSBoolean' cannot have 'JSBoolean' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSString extends JSString {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSString' cannot have 'JSString' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSString implements JSString {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSString' cannot have 'JSString' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ExtendsJSPromise extends JSPromise {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ExtendsJSPromise' cannot have 'JSPromise' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
||||
|
||||
@JS()
|
||||
@staticInterop
|
||||
class ImplementsJSPromise implements JSPromise {}
|
||||
// ^
|
||||
// [web] `@staticInterop` class 'ImplementsJSPromise' cannot have 'JSPromise' as a supertype. `JSObject` and `JSAny` are the only valid supertypes from `dart:js_interop` for `@staticInterop` classes.
|
Loading…
Reference in a new issue