mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
Extension types. Report CONFLICTING_METHOD_AND_FIELD and CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD.
Change-Id: I3ebf1f2f767f2b64cf47e2c80473b086695d20d4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/319869 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Phil Quitslund <pquitslund@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
42b992c947
commit
f6db810b96
|
@ -2046,8 +2046,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||||
name,
|
name,
|
||||||
inherited.enclosingElement.displayName,
|
inherited.enclosingElement.displayName,
|
||||||
]);
|
]);
|
||||||
} else if (inherited is PropertyAccessorElement &&
|
} else if (inherited is PropertyAccessorElement) {
|
||||||
_enclosingClass is! ExtensionTypeElement) {
|
|
||||||
errorReporter.reportErrorForElement(
|
errorReporter.reportErrorForElement(
|
||||||
CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, method, [
|
CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, method, [
|
||||||
_enclosingClass!.displayName,
|
_enclosingClass!.displayName,
|
||||||
|
@ -2074,8 +2073,7 @@ class ErrorVerifier extends RecursiveAstVisitor<void>
|
||||||
name,
|
name,
|
||||||
inherited.enclosingElement.displayName,
|
inherited.enclosingElement.displayName,
|
||||||
]);
|
]);
|
||||||
} else if (inherited is MethodElement &&
|
} else if (inherited is MethodElement) {
|
||||||
_enclosingClass is! ExtensionTypeElement) {
|
|
||||||
errorReporter.reportErrorForElement(
|
errorReporter.reportErrorForElement(
|
||||||
CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, accessor, [
|
CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, accessor, [
|
||||||
_enclosingClass!.displayName,
|
_enclosingClass!.displayName,
|
||||||
|
|
|
@ -100,7 +100,7 @@ enum E with M {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_extensionType_getter() async {
|
test_extensionType_getter() async {
|
||||||
await assertNoErrorsInCode(r'''
|
await assertErrorsInCode(r'''
|
||||||
extension type A(int it) {
|
extension type A(int it) {
|
||||||
void foo() {}
|
void foo() {}
|
||||||
}
|
}
|
||||||
|
@ -108,11 +108,13 @@ extension type A(int it) {
|
||||||
extension type B(int it) implements A {
|
extension type B(int it) implements A {
|
||||||
int get foo => 0;
|
int get foo => 0;
|
||||||
}
|
}
|
||||||
''');
|
''', [
|
||||||
|
error(CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, 96, 3),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
test_extensionType_setter() async {
|
test_extensionType_setter() async {
|
||||||
await assertNoErrorsInCode(r'''
|
await assertErrorsInCode(r'''
|
||||||
extension type A(int it) {
|
extension type A(int it) {
|
||||||
void foo() {}
|
void foo() {}
|
||||||
}
|
}
|
||||||
|
@ -120,6 +122,8 @@ extension type A(int it) {
|
||||||
extension type B(int it) implements A {
|
extension type B(int it) implements A {
|
||||||
set foo(int _) {}
|
set foo(int _) {}
|
||||||
}
|
}
|
||||||
''');
|
''', [
|
||||||
|
error(CompileTimeErrorCode.CONFLICTING_FIELD_AND_METHOD, 92, 3),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ enum E with M {
|
||||||
}
|
}
|
||||||
|
|
||||||
test_extensionType_getter() async {
|
test_extensionType_getter() async {
|
||||||
await assertNoErrorsInCode(r'''
|
await assertErrorsInCode(r'''
|
||||||
extension type A(int it) {
|
extension type A(int it) {
|
||||||
int get foo => 0;
|
int get foo => 0;
|
||||||
}
|
}
|
||||||
|
@ -93,11 +93,13 @@ extension type A(int it) {
|
||||||
extension type B(int it) implements A {
|
extension type B(int it) implements A {
|
||||||
void foo() {}
|
void foo() {}
|
||||||
}
|
}
|
||||||
''');
|
''', [
|
||||||
|
error(CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, 97, 3),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
test_extensionType_setter() async {
|
test_extensionType_setter() async {
|
||||||
await assertNoErrorsInCode(r'''
|
await assertErrorsInCode(r'''
|
||||||
extension type A(int it) {
|
extension type A(int it) {
|
||||||
set foo(int _) {}
|
set foo(int _) {}
|
||||||
}
|
}
|
||||||
|
@ -105,6 +107,8 @@ extension type A(int it) {
|
||||||
extension type B(int it) implements A {
|
extension type B(int it) implements A {
|
||||||
void foo() {}
|
void foo() {}
|
||||||
}
|
}
|
||||||
''');
|
''', [
|
||||||
|
error(CompileTimeErrorCode.CONFLICTING_METHOD_AND_FIELD, 97, 3),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,11 +18,11 @@ class ExtensionTypeDeclaresMemberOfObjectTest extends PubPackageResolutionTest {
|
||||||
test_instance_differentKind() async {
|
test_instance_differentKind() async {
|
||||||
await assertErrorsInCode('''
|
await assertErrorsInCode('''
|
||||||
extension type E(int it) {
|
extension type E(int it) {
|
||||||
void hashCode() {}
|
int get hashCode => 0;
|
||||||
}
|
}
|
||||||
''', [
|
''', [
|
||||||
error(
|
error(
|
||||||
CompileTimeErrorCode.EXTENSION_TYPE_DECLARES_MEMBER_OF_OBJECT, 34, 8),
|
CompileTimeErrorCode.EXTENSION_TYPE_DECLARES_MEMBER_OF_OBJECT, 37, 8),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue