Migrator: Add some failing tests for extensions
Bug: https://github.com/dart-lang/sdk/issues/39387
Change-Id: I2187db2433255fd950789942712d215c2472db4f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149005
Reviewed-by: Paul Berry <paulberry@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
diff --git a/pkg/nnbd_migration/test/api_test.dart b/pkg/nnbd_migration/test/api_test.dart
index f9e515b..6047aa9 100644
--- a/pkg/nnbd_migration/test/api_test.dart
+++ b/pkg/nnbd_migration/test/api_test.dart
@@ -5381,6 +5381,42 @@
await _checkSingleFileChanges(content, expected);
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/39387')
+ Future<void> test_this_inside_extension() async {
+ var content = '''
+class C<T> {
+ T field;
+}
+extension on C<int> {
+ f() {
+ this.field = null;
+ }
+}
+extension on C<List<int>> {
+ f() {
+ this.field = null;
+ }
+}
+''';
+ var expected = '''
+
+class C<T> {
+ T field;
+}
+extension on C<int?> {
+ f() {
+ this.field = null;
+ }
+}
+extension on C<List<int?>> {
+ f() {
+ this.field = [null];
+ }
+}
+''';
+ await _checkSingleFileChanges(content, expected, warnOnWeakCode: true);
+ }
+
Future<void> test_topLevelFunction_parameterType_implicit_dynamic() async {
var content = '''
Object f(x) => x;
diff --git a/pkg/nnbd_migration/test/edge_builder_test.dart b/pkg/nnbd_migration/test/edge_builder_test.dart
index 95c3ce0..c4825b1 100644
--- a/pkg/nnbd_migration/test/edge_builder_test.dart
+++ b/pkg/nnbd_migration/test/edge_builder_test.dart
@@ -2907,6 +2907,31 @@
// metadata was visited.
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/39387')
+ Future<void> test_extension_on_class_with_generic_type_arguments() async {
+ await analyze('''
+class C<T> {}
+void f(C<List> x) {}
+extension E on C<List> {
+ g() => f(this);
+}
+''');
+ // No assertions yet. This test crashes. When it stops crashing, consider
+ // adding assertion(s).
+ }
+
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/39387')
+ Future<void> test_extension_on_function_type() async {
+ await analyze('''
+extension CurryFunction<R, S, T> on R Function(S, T) {
+ /// Curry a binary function with its first argument.
+ R Function(T) curry(S first) => (T second) => this(first, second);
+}
+''');
+ // No assertions yet. This test crashes. When it stops crashing, consider
+ // adding assertion(s).
+ }
+
Future<void> test_field_final_does_not_override_setter() async {
await analyze('''
abstract class A {