blob: 08856f49fd272eb4670d7dbd9ba50ce1ce412dc7 [file] [log] [blame]
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.{core::Object::==}(null) ?{core::int?} null : #t1{self::Class}.{self::Class::next}.{self::Class::field};
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.{core::Object::==}(null) ?{core::int?} null : #t3{self::Class}.{self::Class::field}).{core::num::+}(2));
let final self::Class? #t4 = c in #t4.{core::Object::==}(null) ?{core::int?} null : let final core::int #t5 = #t4.{self::Class::field}.{core::num::+}(1) in let final void #t6 = #t4.{self::Class::field} = #t5 in #t5;
let final self::Class? #t7 = c in #t7.{core::Object::==}(null) ?{core::int?} null : #t7.{self::Class::field} = #t7.{self::Class::field}.{core::num::+}(1);
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.{core::Object::==}(null) ?{self::Class?} null : #t9{self::Class}.{self::Class::next}).{self::Class::field});
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.{core::Object::==}(null) ?{core::int?} null : #t11{self::Class}.{self::Class::field}).{core::int::unary-}());
let final self::Class? #t12 = c in #t12.{core::Object::==}(null) ?{core::bool?} null : #t12{self::Class}.{self::Class::next}.{self::Class::[]}(0).{core::int::isEven};
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.{core::Object::==}(null) ?{core::int?} null : #t14{self::Class}.{self::Class::next}.{self::Class::[]}(0)).{core::num::+}(2));
let final self::Class? #t15 = c in #t15.{core::Object::==}(null) ?{core::int?} null : let final self::Class #t16 = #t15{self::Class}.{self::Class::next} in let final core::int #t17 = 0 in let final core::int #t18 = #t16.{self::Class::[]}(#t17).{core::num::+}(1) in let final void #t19 = #t16.{self::Class::[]=}(#t17, #t18) in #t18;
let final self::Class? #t20 = c in #t20.{core::Object::==}(null) ?{core::int?} null : let final self::Class #t21 = #t20{self::Class}.{self::Class::next} in let final core::int #t22 = 0 in #t21.{self::Class::[]=}(#t22, #t21.{self::Class::[]}(#t22).{core::num::+}(1));
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.{core::Object::==}(null) ?{core::int?} null : #t24{self::Class}.{self::Class::next}.{self::Class::[]}(0)).{core::int::isEven});
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.{core::Object::==}(null) ?{core::int?} null : #t26{self::Class}.{self::Class::next}.{self::Class::[]}(0)).{core::int::unary-}());
}
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};
};
try {
f.call("foo");
}
on core::Object catch(final core::Object e) {
return true;
}
return false;
}
static method throwsInStrong(() → void f) → void {
if(self::inStrongMode) {
try {
f.call();
}
on core::Object catch(final core::Object e) {
core::print(e);
return;
}
throw "Expected exception.";
}
else {
f.call();
}
}
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