Skip to content

Commit fad5548

Browse files
committed
[cfe] Add test for issue for opt-in import of opt-out typedef
Closes #42181 Change-Id: I1557a5843cba6001580d8ff19cd1864e7bc37c48 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/155400 Reviewed-by: Dmitry Stefantsov <[email protected]>
1 parent 3d4bd85 commit fad5548

File tree

6 files changed

+95
-0
lines changed

6 files changed

+95
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'issue42181_lib.dart';
6+
7+
int? f1(int x) => x;
8+
9+
void test() {
10+
F f = null; // Static error
11+
f = f1; // No error
12+
}
13+
14+
main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'issue42181_lib.dart';
2+
3+
int? f1(int x) => x;
4+
void test() {}
5+
main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import 'issue42181_lib.dart';
2+
3+
int? f1(int x) => x;
4+
main() {}
5+
void test() {}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd_mixed/issue42181.dart:10:9: Error: A value of type 'Null' can't be assigned to a variable of type 'int Function(int)'.
6+
// F f = null; // Static error
7+
// ^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
import "org-dartlang-testcase:///issue42181_lib.dart";
13+
14+
static method f1(core::int x) → core::int?
15+
return x;
16+
static method test() → void {
17+
(core::int*) → core::int* f = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd_mixed/issue42181.dart:10:9: Error: A value of type 'Null' can't be assigned to a variable of type 'int Function(int)'.
18+
F f = null; // Static error
19+
^" in null as{TypeError,ForNonNullableByDefault} (core::int*) → core::int*;
20+
f = #C1;
21+
}
22+
static method main() → dynamic {}
23+
24+
library;
25+
import self as self2;
26+
import "dart:core" as core;
27+
28+
typedef F = (core::int*) →* core::int*;
29+
30+
constants {
31+
#C1 = tearoff self::f1
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
library /*isNonNullableByDefault*/;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd_mixed/issue42181.dart:10:9: Error: A value of type 'Null' can't be assigned to a variable of type 'int Function(int)'.
6+
// F f = null; // Static error
7+
// ^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
import "org-dartlang-testcase:///issue42181_lib.dart";
13+
14+
static method f1(core::int x) → core::int?
15+
return x;
16+
static method test() → void {
17+
(core::int*) → core::int* f = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/nnbd_mixed/issue42181.dart:10:9: Error: A value of type 'Null' can't be assigned to a variable of type 'int Function(int)'.
18+
F f = null; // Static error
19+
^" in null;
20+
f = #C1;
21+
}
22+
static method main() → dynamic {}
23+
24+
library;
25+
import self as self2;
26+
import "dart:core" as core;
27+
28+
typedef F = (core::int*) →* core::int*;
29+
30+
constants {
31+
#C1 = tearoff self::f1
32+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// @dart=2.8
6+
7+
typedef F = int Function(int);

0 commit comments

Comments
 (0)