| library /*isNonNullableByDefault*/; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:18:33: Error: Operator '+' cannot be called on 'int?' because it is potentially null. |
| // throwsInStrong(() => c?.field + 2); // error |
| // ^ |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:21:34: Error: Property 'field' cannot be accessed on 'Class?' because it is potentially null. |
| // - 'Class' is from 'pkg/front_end/testcases/nnbd/shorting_stop.dart'. |
| // Try accessing using ?. instead. |
| // throwsInStrong(() => (c?.next).field); // error |
| // ^^^^^ |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:22:24: Error: Operator 'unary-' cannot be called on 'int?' because it is potentially null. |
| // throwsInStrong(() => -c?.field); // error |
| // ^ |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:25:35: Error: Operator '+' cannot be called on 'int?' because it is potentially null. |
| // throwsInStrong(() => c?.next[0] + 2); // error |
| // ^ |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:28:37: Error: Property 'isEven' cannot be accessed on 'int?' because it is potentially null. |
| // Try accessing using ?. instead. |
| // throwsInStrong(() => (c?.next[0]).isEven); // error |
| // ^^^^^^ |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:29:24: Error: Operator 'unary-' cannot be called on 'int?' because it is potentially null. |
| // throwsInStrong(() => -c?.next[0]); // error |
| // ^ |
| // |
| // pkg/front_end/testcases/nnbd/shorting_stop.dart:36:7: Error: Property 'length' cannot be accessed on 'String?' because it is potentially null. |
| // Try accessing using ?. instead. |
| // s.length; // This will be an invalid expression in strong mode. |
| // ^^^^^^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| |
| class Class extends core::Object { |
| field core::int field = 0; |
| synthetic constructor •() → self::Class |
| : super core::Object::•() |
| ; |
| get next() → self::Class |
| return this; |
| operator [](core::int key) → core::int |
| return key; |
| operator []=(core::int key, core::int value) → void {} |
| } |
| static final field core::bool inStrongMode = self::_inStrongMode(); |
| static method main() → dynamic { |
| self::test(new self::Class::•()); |
| } |
| static method test(self::Class? c) → dynamic { |
| let final self::Class? #t1 = c in #t1 == null ?{core::int?} null : #t1{self::Class}.{self::Class::next}{self::Class}.{self::Class::field}{core::int}; |
| self::throwsInStrong(() → void => let final Never #t2 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:18:33: Error: Operator '+' cannot be called on 'int?' because it is potentially null. |
| throwsInStrong(() => c?.field + 2); // error |
| ^" in (let final self::Class? #t3 = c in #t3 == null ?{core::int?} null : #t3{self::Class}.{self::Class::field}{core::int}).{core::num::+}(2){(core::num) → core::num}); |
| let final self::Class? #t4 = c in #t4 == null ?{core::int?} null : let final core::int #t5 = #t4.{self::Class::field}{core::int}.{core::num::+}(1){(core::num) → core::int} in let final void #t6 = #t4.{self::Class::field} = #t5 in #t5; |
| let final self::Class? #t7 = c in #t7 == null ?{core::int?} null : #t7.{self::Class::field} = #t7.{self::Class::field}{core::int}.{core::num::+}(1){(core::num) → core::int}; |
| self::throwsInStrong(() → void => let final Never #t8 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:21:34: Error: Property 'field' cannot be accessed on 'Class?' because it is potentially null. |
| - 'Class' is from 'pkg/front_end/testcases/nnbd/shorting_stop.dart'. |
| Try accessing using ?. instead. |
| throwsInStrong(() => (c?.next).field); // error |
| ^^^^^" in (let final self::Class? #t9 = c in #t9 == null ?{self::Class?} null : #t9{self::Class}.{self::Class::next}{self::Class}).{self::Class::field}{<nullable>}.{core::int}); |
| self::throwsInStrong(() → void => let final Never #t10 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:22:24: Error: Operator 'unary-' cannot be called on 'int?' because it is potentially null. |
| throwsInStrong(() => -c?.field); // error |
| ^" in (let final self::Class? #t11 = c in #t11 == null ?{core::int?} null : #t11{self::Class}.{self::Class::field}{core::int}).{core::int::unary-}(){() → core::int}); |
| let final self::Class? #t12 = c in #t12 == null ?{core::bool?} null : #t12{self::Class}.{self::Class::next}{self::Class}.{self::Class::[]}(0){(core::int) → core::int}.{core::int::isEven}{core::bool}; |
| self::throwsInStrong(() → void => let final Never #t13 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:25:35: Error: Operator '+' cannot be called on 'int?' because it is potentially null. |
| throwsInStrong(() => c?.next[0] + 2); // error |
| ^" in (let final self::Class? #t14 = c in #t14 == null ?{core::int?} null : #t14{self::Class}.{self::Class::next}{self::Class}.{self::Class::[]}(0){(core::int) → core::int}).{core::num::+}(2){(core::num) → core::num}); |
| let final self::Class? #t15 = c in #t15 == null ?{core::int?} null : let final self::Class #t16 = #t15{self::Class}.{self::Class::next}{self::Class} in let final core::int #t17 = 0 in let final core::int #t18 = #t16.{self::Class::[]}(#t17){(core::int) → core::int}.{core::num::+}(1){(core::num) → core::int} in let final void #t19 = #t16.{self::Class::[]=}(#t17, #t18){(core::int, core::int) → void} in #t18; |
| let final self::Class? #t20 = c in #t20 == null ?{core::int?} null : let final self::Class #t21 = #t20{self::Class}.{self::Class::next}{self::Class} in let final core::int #t22 = 0 in #t21.{self::Class::[]=}(#t22, #t21.{self::Class::[]}(#t22){(core::int) → core::int}.{core::num::+}(1){(core::num) → core::int}){(core::int, core::int) → void}; |
| self::throwsInStrong(() → void => let final Never #t23 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:28:37: Error: Property 'isEven' cannot be accessed on 'int?' because it is potentially null. |
| Try accessing using ?. instead. |
| throwsInStrong(() => (c?.next[0]).isEven); // error |
| ^^^^^^" in (let final self::Class? #t24 = c in #t24 == null ?{core::int?} null : #t24{self::Class}.{self::Class::next}{self::Class}.{self::Class::[]}(0){(core::int) → core::int}).{core::int::isEven}{<nullable>}.{core::bool}); |
| self::throwsInStrong(() → void => let final Never #t25 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:29:24: Error: Operator 'unary-' cannot be called on 'int?' because it is potentially null. |
| throwsInStrong(() => -c?.next[0]); // error |
| ^" in (let final self::Class? #t26 = c in #t26 == null ?{core::int?} null : #t26{self::Class}.{self::Class::next}{self::Class}.{self::Class::[]}(0){(core::int) → core::int}).{core::int::unary-}(){() → core::int}); |
| } |
| static method _inStrongMode() → core::bool { |
| (core::String?) → Null f = (core::String? s) → Null { |
| let final Never #t27 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:36:7: Error: Property 'length' cannot be accessed on 'String?' because it is potentially null. |
| Try accessing using ?. instead. |
| s.length; // This will be an invalid expression in strong mode. |
| ^^^^^^" in s.{core::String::length}{<nullable>}.{core::int}; |
| }; |
| try { |
| f("foo"){(core::String?) → Null}; |
| } |
| on core::Object catch(final core::Object e) { |
| return true; |
| } |
| return false; |
| } |
| static method throwsInStrong(() → void f) → void { |
| if(self::inStrongMode) { |
| try { |
| f(){() → void}; |
| } |
| on core::Object catch(final core::Object e) { |
| core::print(e); |
| return; |
| } |
| throw "Expected exception."; |
| } |
| else { |
| f(){() → void}; |
| } |
| } |
| |
| |
| Extra constant evaluation status: |
| Evaluated: VariableGet @ org-dartlang-testcase:///shorting_stop.dart:26:13 -> IntConstant(0) |
| Evaluated: VariableGet @ org-dartlang-testcase:///shorting_stop.dart:26:13 -> IntConstant(0) |
| Evaluated: VariableGet @ org-dartlang-testcase:///shorting_stop.dart:27:11 -> IntConstant(0) |
| Evaluated: VariableGet @ org-dartlang-testcase:///shorting_stop.dart:27:11 -> IntConstant(0) |
| Extra constant evaluation: evaluated: 165, effectively constant: 4 |