mirror of
https://github.com/dart-lang/sdk
synced 2024-10-06 14:07:57 +00:00
[package:js] Add errors for missing @JS on class
Adds errors for class members that have a @JS annotation but the enclosing class does not. Change-Id: Id693af71678510047a723863846d89aa29cebe26 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/157004 Reviewed-by: Nate Bosch <nbosch@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
57a522eaaf
commit
e51623f81a
|
@ -5420,6 +5420,27 @@ const MessageCode messageJsInteropAnonymousFactoryPositionalParameters =
|
|||
r"""Factory constructors for @anonymous JS interop classes should not contain any positional parameters.""",
|
||||
tip: r"""Try replacing them with named parameters instead.""");
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> codeJsInteropEnclosingClassJSAnnotation =
|
||||
messageJsInteropEnclosingClassJSAnnotation;
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const MessageCode messageJsInteropEnclosingClassJSAnnotation = const MessageCode(
|
||||
"JsInteropEnclosingClassJSAnnotation",
|
||||
message:
|
||||
r"""Member has a JS interop annotation but the enclosing class does not.""",
|
||||
tip: r"""Try adding the annotation to the enclosing class.""");
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> codeJsInteropEnclosingClassJSAnnotationContext =
|
||||
messageJsInteropEnclosingClassJSAnnotationContext;
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const MessageCode messageJsInteropEnclosingClassJSAnnotationContext =
|
||||
const MessageCode("JsInteropEnclosingClassJSAnnotationContext",
|
||||
severity: Severity.context,
|
||||
message: r"""This is the enclosing class.""");
|
||||
|
||||
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
|
||||
const Code<Null> codeJsInteropIndexNotSupported =
|
||||
messageJsInteropIndexNotSupported;
|
||||
|
|
|
@ -9,6 +9,8 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
|
|||
Message,
|
||||
LocatedMessage,
|
||||
messageJsInteropAnonymousFactoryPositionalParameters,
|
||||
messageJsInteropEnclosingClassJSAnnotation,
|
||||
messageJsInteropEnclosingClassJSAnnotationContext,
|
||||
messageJsInteropIndexNotSupported,
|
||||
messageJsInteropNamedParameters,
|
||||
messageJsInteropNonExternalConstructor;
|
||||
|
@ -20,8 +22,16 @@ class JsInteropChecks extends RecursiveVisitor<void> {
|
|||
|
||||
JsInteropChecks(this._diagnosticsReporter);
|
||||
|
||||
@override
|
||||
void defaultMember(Member member) {
|
||||
_checkMemberJSInteropAnnotation(member);
|
||||
super.defaultMember(member);
|
||||
}
|
||||
|
||||
@override
|
||||
void visitProcedure(Procedure procedure) {
|
||||
_checkMemberJSInteropAnnotation(procedure);
|
||||
|
||||
if (!procedure.isExternal || !isJSInteropMember(procedure)) return;
|
||||
|
||||
if (!procedure.isStatic &&
|
||||
|
@ -55,6 +65,8 @@ class JsInteropChecks extends RecursiveVisitor<void> {
|
|||
|
||||
@override
|
||||
void visitConstructor(Constructor constructor) {
|
||||
_checkMemberJSInteropAnnotation(constructor);
|
||||
|
||||
if (!isJSInteropMember(constructor)) return;
|
||||
|
||||
if (!constructor.isExternal && !constructor.isSynthetic) {
|
||||
|
@ -79,4 +91,21 @@ class JsInteropChecks extends RecursiveVisitor<void> {
|
|||
firstNamedParam.location.file);
|
||||
}
|
||||
}
|
||||
|
||||
/// Reports an error if [m] has a JS interop annotation and is part of a class
|
||||
/// that does not.
|
||||
void _checkMemberJSInteropAnnotation(Member m) {
|
||||
if (!hasJSInteropAnnotation(m)) return;
|
||||
var enclosingClass = m.enclosingClass;
|
||||
if (enclosingClass != null && !hasJSInteropAnnotation(enclosingClass)) {
|
||||
_diagnosticsReporter.report(messageJsInteropEnclosingClassJSAnnotation,
|
||||
m.fileOffset, m.name.name.length, m.location.file,
|
||||
context: <LocatedMessage>[
|
||||
messageJsInteropEnclosingClassJSAnnotationContext.withLocation(
|
||||
enclosingClass.location.file,
|
||||
enclosingClass.fileOffset,
|
||||
enclosingClass.name.length)
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,6 @@ enum MessageKind {
|
|||
JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER,
|
||||
JS_INTEROP_FIELD_NOT_SUPPORTED,
|
||||
JS_INTEROP_NON_EXTERNAL_MEMBER,
|
||||
JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS,
|
||||
JS_INTEROP_METHOD_WITH_NAMED_ARGUMENTS,
|
||||
JS_OBJECT_LITERAL_CONSTRUCTOR_WITH_POSITIONAL_ARGUMENTS,
|
||||
JS_PLACEHOLDER_CAPTURE,
|
||||
|
@ -201,12 +200,6 @@ class MessageTemplate {
|
|||
MessageKind.JS_INTEROP_NON_EXTERNAL_MEMBER,
|
||||
"Js-interop members must be 'external'."),
|
||||
|
||||
MessageKind.JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS: const MessageTemplate(
|
||||
MessageKind.JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS,
|
||||
"Js-interop class members are only supported in js-interop classes.",
|
||||
howToFix: "Try marking the enclosing class as js-interop or "
|
||||
"remove the js-interop annotation from the member."),
|
||||
|
||||
MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER: const MessageTemplate(
|
||||
MessageKind.JS_INTEROP_CLASS_NON_EXTERNAL_MEMBER,
|
||||
"Member '#{member}' in js-interop class '#{cls}' is not external.",
|
||||
|
|
|
@ -156,10 +156,7 @@ class KernelAnnotationProcessor implements AnnotationProcessor {
|
|||
elementEnvironment.forEachLocalClassMember(cls, (MemberEntity member) {
|
||||
String memberName = getJsInteropName(
|
||||
library, elementEnvironment.getMemberMetadata(member));
|
||||
if (memberName != null) {
|
||||
reporter.reportErrorMessage(
|
||||
member, MessageKind.JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS);
|
||||
} else if (member is FunctionEntity) {
|
||||
if (memberName == null && member is FunctionEntity) {
|
||||
if (member.isExternal &&
|
||||
!commonElements.isExternalAllowed(member)) {
|
||||
reporter.reportErrorMessage(
|
||||
|
@ -171,10 +168,7 @@ class KernelAnnotationProcessor implements AnnotationProcessor {
|
|||
(ConstructorEntity constructor) {
|
||||
String memberName = getJsInteropName(
|
||||
library, elementEnvironment.getMemberMetadata(constructor));
|
||||
if (memberName != null) {
|
||||
reporter.reportErrorMessage(constructor,
|
||||
MessageKind.JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS);
|
||||
} else {
|
||||
if (memberName == null) {
|
||||
if (constructor.isExternal &&
|
||||
!commonElements.isExternalAllowed(constructor)) {
|
||||
reporter.reportErrorMessage(
|
||||
|
|
|
@ -441,6 +441,8 @@ InvalidVoid/script1: Fail
|
|||
InvalidVoid/script2: Fail
|
||||
JsInteropAnonymousFactoryPositionalParameters/analyzerCode: Fail # Web compiler specific
|
||||
JsInteropAnonymousFactoryPositionalParameters/example: Fail # Web compiler specific
|
||||
JsInteropEnclosingClassJSAnnotation/analyzerCode: Fail # Web compiler specific
|
||||
JsInteropEnclosingClassJSAnnotation/example: Fail # Web compiler specific
|
||||
JsInteropIndexNotSupported/analyzerCode: Fail # Web compiler specific
|
||||
JsInteropIndexNotSupported/example: Fail # Web compiler specific
|
||||
JsInteropNamedParameters/analyzerCode: Fail # Web compiler specific
|
||||
|
|
|
@ -4090,6 +4090,14 @@ JsInteropAnonymousFactoryPositionalParameters:
|
|||
template: "Factory constructors for @anonymous JS interop classes should not contain any positional parameters."
|
||||
tip: "Try replacing them with named parameters instead."
|
||||
|
||||
JsInteropEnclosingClassJSAnnotation:
|
||||
template: "Member has a JS interop annotation but the enclosing class does not."
|
||||
tip: "Try adding the annotation to the enclosing class."
|
||||
|
||||
JsInteropEnclosingClassJSAnnotationContext:
|
||||
template: "This is the enclosing class."
|
||||
severity: CONTEXT
|
||||
|
||||
JsInteropIndexNotSupported:
|
||||
template: "JS interop classes do not support [] and []= operator methods."
|
||||
tip: "Try replacing with a normal method."
|
||||
|
|
|
@ -58,16 +58,16 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 09: compile-time error
|
||||
external factory Class.externalFact(); //# 09: continued
|
||||
|
||||
@JS('a') // GENERIC //# 10: compile-time error
|
||||
@JS('a') // GENERIC, GENERIC //# 10: compile-time error
|
||||
Class.jsInteropGenerative(); //# 10: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 11: compile-time error
|
||||
@JS('a') // GENERIC //# 11: compile-time error
|
||||
factory Class.jsInteropFact() => null; //# 11: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 12: compile-time error
|
||||
@JS('a') // GENERIC //# 12: compile-time error
|
||||
external Class.externalJsInteropGenerative(); //# 12: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 13: compile-time error
|
||||
@JS('a') // GENERIC //# 13: compile-time error
|
||||
external factory Class.externalJsInteropFact(); //# 13: continued
|
||||
|
||||
var instanceField;
|
||||
|
@ -80,28 +80,28 @@ class Class {
|
|||
static set staticSetter(_) {}
|
||||
static staticMethod() {}
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 14: compile-time error
|
||||
@JS('a') // GENERIC //# 14: compile-time error
|
||||
var instanceJsInteropField; //# 14: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 15: compile-time error
|
||||
@JS('a') // GENERIC //# 15: compile-time error
|
||||
get instanceJsInteropGetter => null; //# 15: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 16: compile-time error
|
||||
@JS('a') // GENERIC //# 16: compile-time error
|
||||
set instanceJsInteropSetter(_) {} //# 16: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 17: compile-time error
|
||||
@JS('a') // GENERIC //# 17: compile-time error
|
||||
instanceJsInteropMethod() {} //# 17: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 18: compile-time error
|
||||
@JS('a') // GENERIC //# 18: compile-time error
|
||||
static var staticJsInteropField; //# 18: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 19: compile-time error
|
||||
@JS('a') // GENERIC //# 19: compile-time error
|
||||
static get staticJsInteropGetter => null; //# 19: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 20: compile-time error
|
||||
@JS('a') // GENERIC //# 20: compile-time error
|
||||
static set staticJsInteropSetter(_) {} //# 20: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 21: compile-time error
|
||||
@JS('a') // GENERIC //# 21: compile-time error
|
||||
static staticJsInteropMethod() {} //# 21: continued
|
||||
|
||||
// NON_NATIVE_EXTERNAL //# 22: compile-time error
|
||||
|
@ -122,22 +122,22 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 27: compile-time error
|
||||
external static externalStaticMethod(); //# 27: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 28: compile-time error
|
||||
@JS('a') // GENERIC //# 28: compile-time error
|
||||
external get externalInstanceJsInteropGetter; //# 28: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 29: compile-time error
|
||||
@JS('a') // GENERIC //# 29: compile-time error
|
||||
external set externalInstanceJsInteropSetter(_); //# 29: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 30: compile-time error
|
||||
@JS('a') // GENERIC //# 30: compile-time error
|
||||
external externalInstanceJsInteropMethod(); //# 30: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 31: compile-time error
|
||||
@JS('a') // GENERIC //# 31: compile-time error
|
||||
external static get externalStaticJsInteropGetter; //# 31: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 32: compile-time error
|
||||
@JS('a') // GENERIC //# 32: compile-time error
|
||||
external static set externalStaticJsInteropSetter(_); //# 32: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 33: compile-time error
|
||||
@JS('a') // GENERIC //# 33: compile-time error
|
||||
external static externalStaticJsInteropMethod(); //# 33: continued
|
||||
}
|
||||
|
||||
|
|
|
@ -60,16 +60,16 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 09: compile-time error
|
||||
external factory Class.externalFact(); //# 09: continued
|
||||
|
||||
@JS('a') // GENERIC //# 10: compile-time error
|
||||
@JS('a') // GENERIC, GENERIC //# 10: compile-time error
|
||||
Class.jsInteropGenerative(); //# 10: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 11: compile-time error
|
||||
@JS('a') // GENERIC //# 11: compile-time error
|
||||
factory Class.jsInteropFact() => null; //# 11: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 12: compile-time error
|
||||
@JS('a') // GENERIC //# 12: compile-time error
|
||||
external Class.externalJsInteropGenerative(); //# 12: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 13: compile-time error
|
||||
@JS('a') // GENERIC //# 13: compile-time error
|
||||
external factory Class.externalJsInteropFact(); //# 13: continued
|
||||
|
||||
var instanceField;
|
||||
|
@ -82,28 +82,28 @@ class Class {
|
|||
static set staticSetter(_) {}
|
||||
static staticMethod() {}
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 14: compile-time error
|
||||
@JS('a') // GENERIC //# 14: compile-time error
|
||||
var instanceJsInteropField; //# 14: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 15: compile-time error
|
||||
@JS('a') // GENERIC //# 15: compile-time error
|
||||
get instanceJsInteropGetter => null; //# 15: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 16: compile-time error
|
||||
@JS('a') // GENERIC //# 16: compile-time error
|
||||
set instanceJsInteropSetter(_) {} //# 16: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 17: compile-time error
|
||||
@JS('a') // GENERIC //# 17: compile-time error
|
||||
instanceJsInteropMethod() {} //# 17: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 18: compile-time error
|
||||
@JS('a') // GENERIC //# 18: compile-time error
|
||||
static var staticJsInteropField; //# 18: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 19: compile-time error
|
||||
@JS('a') // GENERIC //# 19: compile-time error
|
||||
static get staticJsInteropGetter => null; //# 19: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 20: compile-time error
|
||||
@JS('a') // GENERIC //# 20: compile-time error
|
||||
static set staticJsInteropSetter(_) {} //# 20: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 21: compile-time error
|
||||
@JS('a') // GENERIC //# 21: compile-time error
|
||||
static staticJsInteropMethod() {} //# 21: continued
|
||||
|
||||
// NON_NATIVE_EXTERNAL //# 22: compile-time error
|
||||
|
@ -124,22 +124,22 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 27: compile-time error
|
||||
external static externalStaticMethod(); //# 27: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 28: compile-time error
|
||||
@JS('a') // GENERIC //# 28: compile-time error
|
||||
external get externalInstanceJsInteropGetter; //# 28: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 29: compile-time error
|
||||
@JS('a') // GENERIC //# 29: compile-time error
|
||||
external set externalInstanceJsInteropSetter(_); //# 29: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 30: compile-time error
|
||||
@JS('a') // GENERIC //# 30: compile-time error
|
||||
external externalInstanceJsInteropMethod(); //# 30: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 31: compile-time error
|
||||
@JS('a') // GENERIC //# 31: compile-time error
|
||||
external static get externalStaticJsInteropGetter; //# 31: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 32: compile-time error
|
||||
@JS('a') // GENERIC //# 32: compile-time error
|
||||
external static set externalStaticJsInteropSetter(_); //# 32: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 33: compile-time error
|
||||
@JS('a') // GENERIC //# 33: compile-time error
|
||||
external static externalStaticJsInteropMethod(); //# 33: continued
|
||||
}
|
||||
|
||||
|
|
|
@ -60,16 +60,16 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 09: compile-time error
|
||||
external factory Class.externalFact(); //# 09: continued
|
||||
|
||||
@JS('a') // GENERIC //# 10: compile-time error
|
||||
@JS('a') // GENERIC, GENERIC //# 10: compile-time error
|
||||
Class.jsInteropGenerative(); //# 10: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 11: compile-time error
|
||||
@JS('a') // GENERIC //# 11: compile-time error
|
||||
factory Class.jsInteropFact() => null; //# 11: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 12: compile-time error
|
||||
@JS('a') // GENERIC //# 12: compile-time error
|
||||
external Class.externalJsInteropGenerative(); //# 12: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 13: compile-time error
|
||||
@JS('a') // GENERIC //# 13: compile-time error
|
||||
external factory Class.externalJsInteropFact(); //# 13: continued
|
||||
|
||||
var instanceField;
|
||||
|
@ -82,28 +82,28 @@ class Class {
|
|||
static set staticSetter(_) {}
|
||||
static staticMethod() {}
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 14: compile-time error
|
||||
@JS('a') // GENERIC //# 14: compile-time error
|
||||
var instanceJsInteropField; //# 14: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 15: compile-time error
|
||||
@JS('a') // GENERIC //# 15: compile-time error
|
||||
get instanceJsInteropGetter => null; //# 15: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 16: compile-time error
|
||||
@JS('a') // GENERIC //# 16: compile-time error
|
||||
set instanceJsInteropSetter(_) {} //# 16: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 17: compile-time error
|
||||
@JS('a') // GENERIC //# 17: compile-time error
|
||||
instanceJsInteropMethod() {} //# 17: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 18: compile-time error
|
||||
@JS('a') // GENERIC //# 18: compile-time error
|
||||
static var staticJsInteropField; //# 18: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 19: compile-time error
|
||||
@JS('a') // GENERIC //# 19: compile-time error
|
||||
static get staticJsInteropGetter => null; //# 19: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 20: compile-time error
|
||||
@JS('a') // GENERIC //# 20: compile-time error
|
||||
static set staticJsInteropSetter(_) {} //# 20: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 21: compile-time error
|
||||
@JS('a') // GENERIC //# 21: compile-time error
|
||||
static staticJsInteropMethod() {} //# 21: continued
|
||||
|
||||
// NON_NATIVE_EXTERNAL //# 22: compile-time error
|
||||
|
@ -124,22 +124,22 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 27: compile-time error
|
||||
external static externalStaticMethod(); //# 27: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 28: compile-time error
|
||||
@JS('a') // GENERIC //# 28: compile-time error
|
||||
external get externalInstanceJsInteropGetter; //# 28: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 29: compile-time error
|
||||
@JS('a') // GENERIC //# 29: compile-time error
|
||||
external set externalInstanceJsInteropSetter(_); //# 29: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 30: compile-time error
|
||||
@JS('a') // GENERIC //# 30: compile-time error
|
||||
external externalInstanceJsInteropMethod(); //# 30: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 31: compile-time error
|
||||
@JS('a') // GENERIC //# 31: compile-time error
|
||||
external static get externalStaticJsInteropGetter; //# 31: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 32: compile-time error
|
||||
@JS('a') // GENERIC //# 32: compile-time error
|
||||
external static set externalStaticJsInteropSetter(_); //# 32: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 33: compile-time error
|
||||
@JS('a') // GENERIC //# 33: compile-time error
|
||||
external static externalStaticJsInteropMethod(); //# 33: continued
|
||||
}
|
||||
|
||||
|
|
|
@ -62,16 +62,16 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 09: compile-time error
|
||||
external factory Class.externalFact(); //# 09: continued
|
||||
|
||||
@JS('a') // GENERIC //# 10: compile-time error
|
||||
@JS('a') // GENERIC, GENERIC //# 10: compile-time error
|
||||
Class.jsInteropGenerative(); //# 10: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 11: compile-time error
|
||||
@JS('a') // GENERIC //# 11: compile-time error
|
||||
factory Class.jsInteropFact() => null; //# 11: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 12: compile-time error
|
||||
@JS('a') // GENERIC //# 12: compile-time error
|
||||
external Class.externalJsInteropGenerative(); //# 12: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 13: compile-time error
|
||||
@JS('a') // GENERIC //# 13: compile-time error
|
||||
external factory Class.externalJsInteropFact(); //# 13: continued
|
||||
|
||||
var instanceField;
|
||||
|
@ -84,28 +84,28 @@ class Class {
|
|||
static set staticSetter(_) {}
|
||||
static staticMethod() {}
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 14: compile-time error
|
||||
@JS('a') // GENERIC //# 14: compile-time error
|
||||
var instanceJsInteropField; //# 14: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 15: compile-time error
|
||||
@JS('a') // GENERIC //# 15: compile-time error
|
||||
get instanceJsInteropGetter => null; //# 15: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 16: compile-time error
|
||||
@JS('a') // GENERIC //# 16: compile-time error
|
||||
set instanceJsInteropSetter(_) {} //# 16: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 17: compile-time error
|
||||
@JS('a') // GENERIC //# 17: compile-time error
|
||||
instanceJsInteropMethod() {} //# 17: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 18: compile-time error
|
||||
@JS('a') // GENERIC //# 18: compile-time error
|
||||
static var staticJsInteropField; //# 18: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 19: compile-time error
|
||||
@JS('a') // GENERIC //# 19: compile-time error
|
||||
static get staticJsInteropGetter => null; //# 19: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 20: compile-time error
|
||||
@JS('a') // GENERIC //# 20: compile-time error
|
||||
static set staticJsInteropSetter(_) {} //# 20: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 21: compile-time error
|
||||
@JS('a') // GENERIC //# 21: compile-time error
|
||||
static staticJsInteropMethod() {} //# 21: continued
|
||||
|
||||
// NON_NATIVE_EXTERNAL //# 22: compile-time error
|
||||
|
@ -126,22 +126,22 @@ class Class {
|
|||
// NON_NATIVE_EXTERNAL //# 27: compile-time error
|
||||
external static externalStaticMethod(); //# 27: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 28: compile-time error
|
||||
@JS('a') // GENERIC //# 28: compile-time error
|
||||
external get externalInstanceJsInteropGetter; //# 28: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 29: compile-time error
|
||||
@JS('a') // GENERIC //# 29: compile-time error
|
||||
external set externalInstanceJsInteropSetter(_); //# 29: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 30: compile-time error
|
||||
@JS('a') // GENERIC //# 30: compile-time error
|
||||
external externalInstanceJsInteropMethod(); //# 30: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 31: compile-time error
|
||||
@JS('a') // GENERIC //# 31: compile-time error
|
||||
external static get externalStaticJsInteropGetter; //# 31: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 32: compile-time error
|
||||
@JS('a') // GENERIC //# 32: compile-time error
|
||||
external static set externalStaticJsInteropSetter(_); //# 32: continued
|
||||
|
||||
@JS('a') // JS_INTEROP_MEMBER_IN_NON_JS_INTEROP_CLASS //# 33: compile-time error
|
||||
@JS('a') // GENERIC //# 33: compile-time error
|
||||
external static externalStaticJsInteropMethod(); //# 33: continued
|
||||
}
|
||||
|
||||
|
|
46
tests/lib/js/js_annotation_static_test.dart
Normal file
46
tests/lib/js/js_annotation_static_test.dart
Normal file
|
@ -0,0 +1,46 @@
|
|||
// Copyright (c) 2020, 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.
|
||||
|
||||
// TODO(srujzs): Fix this test once web static error testing is supported.
|
||||
|
||||
// Tests static errors for incorrect JS annotations.
|
||||
|
||||
@JS()
|
||||
library js_annotation_static_test;
|
||||
|
||||
import 'package:js/js.dart';
|
||||
|
||||
class Foo {
|
||||
// ^^^
|
||||
// [web] TODO(srujzs): Test context once supported.
|
||||
@JS()
|
||||
external Foo(int bar);
|
||||
// ^
|
||||
// [web] TODO(srujzs): Add error once supported.
|
||||
@JS()
|
||||
external factory Foo.fooFactory();
|
||||
// ^
|
||||
// [web] TODO(srujzs): Add error once supported.
|
||||
@JS()
|
||||
external int get bar;
|
||||
// ^^^
|
||||
// [web] TODO(srujzs): Add error once supported.
|
||||
@JS()
|
||||
external set bar(int val);
|
||||
// ^^^
|
||||
// [web] TODO(srujzs): Add error once supported.
|
||||
@JS()
|
||||
external int baz();
|
||||
// ^^^
|
||||
// [web] TODO(srujzs): Add error once supported.
|
||||
@JS()
|
||||
external static int bazStatic();
|
||||
// ^^^^^^^^^
|
||||
// [web] TODO(srujzs): Add error once supported.
|
||||
}
|
||||
|
||||
@JS()
|
||||
external int qux();
|
||||
|
||||
main() {}
|
Loading…
Reference in a new issue