Skip to content

Commit

Permalink
Add failing tests for summaries and referencing / invoking static met…
Browse files Browse the repository at this point in the history
…hods 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]>
  • Loading branch information
scheglov authored and [email protected] committed Jul 25, 2019
1 parent 20f17c7 commit aac3ce5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pkg/analyzer/test/src/summary/resynthesize_ast_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ class ResynthesizeAstStrongTest extends ResynthesizeTestStrategyTwoPhase

@override
@failingTest
test_defaultValue_refersToExtension_method() async {
await super.test_defaultValue_refersToExtension_method();
test_defaultValue_refersToExtension_method_inside() async {
await super.test_defaultValue_refersToExtension_method_inside();
}

@override
Expand Down
52 changes: 46 additions & 6 deletions pkg/analyzer/test/src/summary/resynthesize_common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:analyzer/src/summary/resynthesize.dart';
import 'package:analyzer/src/test_utilities/mock_sdk.dart';
import 'package:analyzer/src/test_utilities/resource_provider_mixin.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';

import '../../util/element_type_matchers.dart';
import 'element_text.dart';
Expand Down Expand Up @@ -3608,6 +3609,28 @@ const int Function(int, String) V =
''');
}

@FailingTest(reason: 'Resolution is not implemented yet for extensions')
test_const_reference_staticMethod_ofExtension() async {
featureSet = enableExtensionMethods;
var library = await checkLibrary('''
class A {}
extension E on A {
static void f() {}
}
const x = E.f;
''');
checkElementText(library, r'''
class A {
}
extension E on A {
static void f() {}
}
const void Function() x =
E/*location: test.dart;E*/.
f/*location: test.dart;E;f*/;
''');
}

test_const_reference_topLevelFunction() async {
var library = await checkLibrary(r'''
foo() {}
Expand Down Expand Up @@ -5124,7 +5147,7 @@ void defaultF<T>(T v) {}
''');
}

test_defaultValue_refersToExtension_method() async {
test_defaultValue_refersToExtension_method_inside() async {
featureSet = enableExtensionMethods;
var library = await checkLibrary('''
class A {}
Expand All @@ -5133,18 +5156,15 @@ extension E on A {
static void g([Object p = f]) {}
}
''');
checkElementText(
library,
r'''
checkElementText(library, r'''
class A {
}
extension E on A {
static void f() {}
static void g([Object p =
f/*location: test.dart;E;f*/]) {}
}
''',
withTypes: true);
''');
}

test_defaultValue_refersToGenericClass() async {
Expand Down Expand Up @@ -10845,6 +10865,26 @@ final int v;
''');
}

@FailingTest(reason: 'Resolution is not implemented yet for extensions')
test_variable_initializer_staticMethod_ofExtension() async {
featureSet = enableExtensionMethods;
var library = await checkLibrary('''
class A {}
extension E on A {
static int f() => 0;
}
var x = E.f();
''');
checkElementText(library, r'''
class A {
}
extension E on A {
static int f() {}
}
int x;
''');
}

test_variable_initializer_untyped() async {
var library = await checkLibrary('var v = 0;');
checkElementText(library, r'''
Expand Down

0 comments on commit aac3ce5

Please sign in to comment.