Skip to content

Commit 9cd13cd

Browse files
johnniwinthercommit-bot@chromium.org
authored andcommitted
[cfe] Add test for issue42607
This verifies that we no longer emit spurious errors/warnings in opted out libraries when trying to compile with sound null safety. Closes flutter#42607 Change-Id: I89063003fb5140d9cd0a3ce937017976e2fdd1c7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/169740 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
1 parent 5cc2ca1 commit 9cd13cd

8 files changed

+87
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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.6
6+
7+
test() {
8+
int x = 3;
9+
x?.isEven;
10+
x = null;
11+
}
12+
13+
main() {}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42607.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
6+
// // @dart = 2.6
7+
// ^^^^^^^^^^^^^^
8+
//
9+
import self as self;
10+
11+
static method test() → dynamic
12+
;
13+
static method main() → dynamic
14+
;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42607.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
6+
// // @dart = 2.6
7+
// ^^^^^^^^^^^^^^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
static method test() → dynamic {
13+
core::int* x = 3;
14+
let final core::int* #t1 = x in #t1.{core::num::==}(null) ?{core::bool*} null : #t1.{core::int::isEven};
15+
x = null;
16+
}
17+
static method main() → dynamic {}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/nnbd/issue42607.dart:5:1: Error: A library can't opt out of null safety by default, when using sound null safety.
6+
// // @dart = 2.6
7+
// ^^^^^^^^^^^^^^
8+
//
9+
import self as self;
10+
import "dart:core" as core;
11+
12+
static method test() → dynamic {
13+
core::int* x = 3;
14+
let final core::int* #t1 = x in #t1.{core::num::==}(null) ?{core::bool*} null : #t1.{core::int::isEven};
15+
x = null;
16+
}
17+
static method main() → dynamic {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @dart = 2.6
2+
test() {}
3+
main() {}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// @dart = 2.6
2+
main() {}
3+
test() {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
static method test() → dynamic {
6+
core::int* x = 3;
7+
let final core::int* #t1 = x in #t1.{core::num::==}(null) ?{core::bool*} null : #t1.{core::int::isEven};
8+
x = null;
9+
}
10+
static method main() → dynamic {}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
library;
2+
import self as self;
3+
import "dart:core" as core;
4+
5+
static method test() → dynamic {
6+
core::int* x = 3;
7+
let final core::int* #t1 = x in #t1.{core::num::==}(null) ?{core::bool*} null : #t1.{core::int::isEven};
8+
x = null;
9+
}
10+
static method main() → dynamic {}

0 commit comments

Comments
 (0)