Additional fix for #491. Null aware operator tests added
diff --git a/LanguageFeatures/nnbd/legacy_library_lib.dart b/LanguageFeatures/nnbd/legacy_library_lib.dart
index 7022542..678fb1a 100644
--- a/LanguageFeatures/nnbd/legacy_library_lib.dart
+++ b/LanguageFeatures/nnbd/legacy_library_lib.dart
@@ -16,6 +16,8 @@
String text = "Let it be";
int operator[](int index) => index;
void operator[]=(int index, var value) => value;
+
+ AMx c = new AMx();
}
class C<X extends A> {
diff --git a/LanguageFeatures/nnbd/null_aware_operator_A01_t03.dart b/LanguageFeatures/nnbd/null_aware_operator_A01_t03.dart
index f0539ad..0150962 100644
--- a/LanguageFeatures/nnbd/null_aware_operator_A01_t03.dart
+++ b/LanguageFeatures/nnbd/null_aware_operator_A01_t03.dart
@@ -10,6 +10,7 @@
* @description Check that a property access e?.f translates to:
* SHORT[EXP(e), fn[x] => x.f]. Test type aliases
* @author sgrekhov@unipro.ru
+ * @static-warning
*/
// SharedOptions=--enable-experiment=non-nullable,nonfunction-type-aliases
import "../../Utils/expect.dart";
diff --git a/LanguageFeatures/nnbd/null_aware_operator_A02_t01.dart b/LanguageFeatures/nnbd/null_aware_operator_A02_t01.dart
new file mode 100644
index 0000000..63f6f89
--- /dev/null
+++ b/LanguageFeatures/nnbd/null_aware_operator_A02_t01.dart
@@ -0,0 +1,32 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion If e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]
+ *
+ * @description Check that if e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+import "../../Utils/expect.dart";
+
+class A {
+ C c = new C();
+}
+
+class C {
+ String test = "Lily was here";
+}
+
+main() {
+ C c = new C();
+ Expect.equals("Lily was here", c.test);
+ A? a = null;
+ Expect.throws(() {a?.c.test;}, (e) => e is NoSuchMethodError);
+ a = new A();
+ Expect.equals("Lily was here", a?.c.test);
+}
diff --git a/LanguageFeatures/nnbd/null_aware_operator_A02_t02.dart b/LanguageFeatures/nnbd/null_aware_operator_A02_t02.dart
new file mode 100644
index 0000000..885319e
--- /dev/null
+++ b/LanguageFeatures/nnbd/null_aware_operator_A02_t02.dart
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion If e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]
+ *
+ * @description Check that if e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]
+ * @static-warning
+ * @author sgrekhov@unipro.ru
+ */
+// SharedOptions=--enable-experiment=non-nullable
+import "../../Utils/expect.dart";
+
+class A {
+ C? c = new C();
+}
+
+class C {
+ String test = "Lily was here";
+}
+
+main() {
+ A a = new A();
+ Expect.equals("Lily was here", a?.c.test); /// static type warning
+ a.c = null;
+ Expect.throws(() {a.c.test;}, (e) => e is NoSuchMethodError);
+}
diff --git a/LanguageFeatures/nnbd/null_aware_operator_A02_t03.dart b/LanguageFeatures/nnbd/null_aware_operator_A02_t03.dart
new file mode 100644
index 0000000..8ca64ed
--- /dev/null
+++ b/LanguageFeatures/nnbd/null_aware_operator_A02_t03.dart
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion If e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]
+ *
+ * @description Check that if e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]. Test type aliases
+ * @author sgrekhov@unipro.ru
+ * @static-warning
+ */
+// SharedOptions=--enable-experiment=non-nullable,nonfunction-type-aliases
+import "../../Utils/expect.dart";
+
+class A {
+ C c = new C();
+}
+
+class C {
+ String test = "Lily was here";
+}
+
+typedef AAlias1 = A?;
+typedef AAlias2 = A;
+typedef CAlias = C;
+
+main() {
+ CAlias c = new C();
+ Expect.equals("Lily was here", c.test);
+ AAlias1 a1 = null;
+ Expect.throws(() {a1?.c.test;}, (e) => e is NoSuchMethodError);
+ a1 = new A();
+ Expect.equals("Lily was here", a1?.c.test);
+
+ AAlias2? a2 = null;
+ Expect.throws(() {a2?.c.test;}, (e) => e is NoSuchMethodError);
+ a2 = new A();
+ Expect.equals("Lily was here", a2?.c.test);
+
+ AAlias2 a3 = new A();
+ Expect.equals("Lily was here", a3?.c.test); /// static type warning
+}
diff --git a/LanguageFeatures/nnbd/null_aware_operator_A02_t04.dart b/LanguageFeatures/nnbd/null_aware_operator_A02_t04.dart
new file mode 100644
index 0000000..09512e4
--- /dev/null
+++ b/LanguageFeatures/nnbd/null_aware_operator_A02_t04.dart
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
+ * for details. All rights reserved. Use of this source code is governed by a
+ * BSD-style license that can be found in the LICENSE file.
+ */
+/**
+ * @assertion If e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]
+ *
+ * @description Check that if e translates to F then e.f translates to:
+ * PASSTHRU[F, fn[x] => x.f]. Test legacy pre-NNBD types
+ * @author sgrekhov@unipro.ru
+ * @static-warning
+ */
+// SharedOptions=--enable-experiment=non-nullable
+import "../../Utils/expect.dart";
+import "legacy_library_lib.dart";
+
+main() {
+ AMx c = new AMx();
+ Expect.equals("No woman, no cry", c.text);
+
+ A? a1 = null;
+ Expect.throws(() {a1?.c.text;}, (e) => e is NoSuchMethodError);
+ a1 = new A();
+ Expect.equals("No woman, no cry", a1?.c.text);
+
+ A a2 = new A();
+ Expect.equals("No woman, no cry", a2?.c.text); /// static type warning
+}