Skip to content

Commit aac3ce5

Browse files
scheglovcommit-bot@chromium.org
authored andcommitted
Add failing tests for summaries and referencing / invoking static methods of extensions.
As requested in https://dart-review.googlesource.com/c/sdk/+/110363 [email protected], [email protected] Change-Id: I8f2aba0ea02e4857bba253131d2b73e17eaebcd4 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/110520 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Konstantin Shcheglov <[email protected]>
1 parent 20f17c7 commit aac3ce5

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed

pkg/analyzer/test/src/summary/resynthesize_ast_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ class ResynthesizeAstStrongTest extends ResynthesizeTestStrategyTwoPhase
4040

4141
@override
4242
@failingTest
43-
test_defaultValue_refersToExtension_method() async {
44-
await super.test_defaultValue_refersToExtension_method();
43+
test_defaultValue_refersToExtension_method_inside() async {
44+
await super.test_defaultValue_refersToExtension_method_inside();
4545
}
4646

4747
@override

pkg/analyzer/test/src/summary/resynthesize_common.dart

Lines changed: 46 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import 'package:analyzer/src/summary/resynthesize.dart';
1919
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
2020
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
2121
import 'package:test/test.dart';
22+
import 'package:test_reflective_loader/test_reflective_loader.dart';
2223

2324
import '../../util/element_type_matchers.dart';
2425
import 'element_text.dart';
@@ -3608,6 +3609,28 @@ const int Function(int, String) V =
36083609
''');
36093610
}
36103611

3612+
@FailingTest(reason: 'Resolution is not implemented yet for extensions')
3613+
test_const_reference_staticMethod_ofExtension() async {
3614+
featureSet = enableExtensionMethods;
3615+
var library = await checkLibrary('''
3616+
class A {}
3617+
extension E on A {
3618+
static void f() {}
3619+
}
3620+
const x = E.f;
3621+
''');
3622+
checkElementText(library, r'''
3623+
class A {
3624+
}
3625+
extension E on A {
3626+
static void f() {}
3627+
}
3628+
const void Function() x =
3629+
E/*location: test.dart;E*/.
3630+
f/*location: test.dart;E;f*/;
3631+
''');
3632+
}
3633+
36113634
test_const_reference_topLevelFunction() async {
36123635
var library = await checkLibrary(r'''
36133636
foo() {}
@@ -5124,7 +5147,7 @@ void defaultF<T>(T v) {}
51245147
''');
51255148
}
51265149

5127-
test_defaultValue_refersToExtension_method() async {
5150+
test_defaultValue_refersToExtension_method_inside() async {
51285151
featureSet = enableExtensionMethods;
51295152
var library = await checkLibrary('''
51305153
class A {}
@@ -5133,18 +5156,15 @@ extension E on A {
51335156
static void g([Object p = f]) {}
51345157
}
51355158
''');
5136-
checkElementText(
5137-
library,
5138-
r'''
5159+
checkElementText(library, r'''
51395160
class A {
51405161
}
51415162
extension E on A {
51425163
static void f() {}
51435164
static void g([Object p =
51445165
f/*location: test.dart;E;f*/]) {}
51455166
}
5146-
''',
5147-
withTypes: true);
5167+
''');
51485168
}
51495169

51505170
test_defaultValue_refersToGenericClass() async {
@@ -10845,6 +10865,26 @@ final int v;
1084510865
''');
1084610866
}
1084710867

10868+
@FailingTest(reason: 'Resolution is not implemented yet for extensions')
10869+
test_variable_initializer_staticMethod_ofExtension() async {
10870+
featureSet = enableExtensionMethods;
10871+
var library = await checkLibrary('''
10872+
class A {}
10873+
extension E on A {
10874+
static int f() => 0;
10875+
}
10876+
var x = E.f();
10877+
''');
10878+
checkElementText(library, r'''
10879+
class A {
10880+
}
10881+
extension E on A {
10882+
static int f() {}
10883+
}
10884+
int x;
10885+
''');
10886+
}
10887+
1084810888
test_variable_initializer_untyped() async {
1084910889
var library = await checkLibrary('var v = 0;');
1085010890
checkElementText(library, r'''

0 commit comments

Comments
 (0)