-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extension type. Report EXTENSION_TYPE_WITH_ABSTRACT_MEMBER.
dart-lang/language@913b81e Change-Id: Ic3303744ea4c1f2cc90df63a3ae52b51861757ca Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/322983 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
- Loading branch information
Showing
7 changed files
with
144 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
pkg/analyzer/test/src/diagnostics/extension_type_with_abstract_member_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// 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. | ||
|
||
import 'package:analyzer/src/dart/error/syntactic_errors.dart'; | ||
import 'package:analyzer/src/error/codes.dart'; | ||
import 'package:test_reflective_loader/test_reflective_loader.dart'; | ||
|
||
import '../dart/resolution/context_collection_resolution.dart'; | ||
|
||
main() { | ||
defineReflectiveSuite(() { | ||
defineReflectiveTests(ExtensionTypeWithAbstractMemberTest); | ||
}); | ||
} | ||
|
||
@reflectiveTest | ||
class ExtensionTypeWithAbstractMemberTest extends PubPackageResolutionTest { | ||
test_getter() async { | ||
await assertErrorsInCode(''' | ||
extension type A(int it) { | ||
int get foo; | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.EXTENSION_TYPE_WITH_ABSTRACT_MEMBER, 29, 12), | ||
]); | ||
} | ||
|
||
test_getter_external() async { | ||
await assertNoErrorsInCode(''' | ||
extension type A(int it) { | ||
external int get foo; | ||
} | ||
'''); | ||
} | ||
|
||
test_getter_static() async { | ||
await assertErrorsInCode(''' | ||
extension type A(int it) { | ||
static int get foo; | ||
} | ||
''', [ | ||
error(ParserErrorCode.MISSING_FUNCTION_BODY, 47, 1), | ||
]); | ||
} | ||
|
||
test_method() async { | ||
await assertErrorsInCode(''' | ||
extension type A(int it) { | ||
void foo(); | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.EXTENSION_TYPE_WITH_ABSTRACT_MEMBER, 29, 11), | ||
]); | ||
} | ||
|
||
test_method_external() async { | ||
await assertNoErrorsInCode(''' | ||
extension type A(int it) { | ||
external void foo(); | ||
} | ||
'''); | ||
} | ||
|
||
test_method_static() async { | ||
await assertErrorsInCode(''' | ||
extension type A(int it) { | ||
static void foo(); | ||
} | ||
''', [ | ||
error(ParserErrorCode.MISSING_FUNCTION_BODY, 46, 1), | ||
]); | ||
} | ||
|
||
test_setter() async { | ||
await assertErrorsInCode(''' | ||
extension type A(int it) { | ||
set foo(int _); | ||
} | ||
''', [ | ||
error(CompileTimeErrorCode.EXTENSION_TYPE_WITH_ABSTRACT_MEMBER, 29, 15), | ||
]); | ||
} | ||
|
||
test_setter_external() async { | ||
await assertNoErrorsInCode(''' | ||
extension type A(int it) { | ||
external set foo(int _); | ||
} | ||
'''); | ||
} | ||
|
||
test_setter_static() async { | ||
await assertErrorsInCode(''' | ||
extension type A(int it) { | ||
static set foo(int _); | ||
} | ||
''', [ | ||
error(ParserErrorCode.MISSING_FUNCTION_BODY, 50, 1), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters