blob: fe0c7201f87c470f92825ab47a01a705fc6cd750 [file] [log] [blame]
library;
//
// 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:22: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: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:29: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: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(() core::int => let final<BottomType> #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(() → core::int => let final<BottomType> #t8 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:22: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});
let final self::Class? #t10 = c in #t10.{core::Object::==}(null) ?{core::bool?} null : #t10{self::Class}.{self::Class::next}.{self::Class::[]}(0).{core::int::isEven};
self::throwsInStrong(() → core::int => let final<BottomType> #t11 = 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? #t12 = c in #t12.{core::Object::==}(null) ?{core::int?} null : #t12{self::Class}.{self::Class::next}.{self::Class::[]}(0)).{core::num::+}(2));
let final self::Class? #t13 = c in #t13.{core::Object::==}(null) ?{core::int?} null : let final self::Class #t14 = #t13{self::Class}.{self::Class::next} in let final core::int #t15 = 0 in let final core::int #t16 = #t14.{self::Class::[]}(#t15).{core::num::+}(1) in let final void #t17 = #t14.{self::Class::[]=}(#t15, #t16) in #t16;
let final self::Class? #t18 = c in #t18.{core::Object::==}(null) ?{core::int?} null : let final self::Class #t19 = #t18{self::Class}.{self::Class::next} in let final core::int #t20 = 0 in #t19.{self::Class::[]=}(#t20, #t19.{self::Class::[]}(#t20).{core::num::+}(1));
self::throwsInStrong(() → core::bool* => let final<BottomType> #t21 = invalid-expression "pkg/front_end/testcases/nnbd/shorting_stop.dart:29: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? #t22 = c in #t22.{core::Object::==}(null) ?{core::int?} null : #t22{self::Class}.{self::Class::next}.{self::Class::[]}(0)).{core::int::isEven});
}
static method _inStrongMode() → core::bool {
(core::String?) → core::Null? f = (core::String? s) → core::Null? {
let final<BottomType> #t23 = 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 dynamic catch(final dynamic e) {
return true;
}
return false;
}
static method throwsInStrong(() → void f) → void {
if(self::inStrongMode) {
try {
f.call();
}
on dynamic catch(final dynamic e) {
core::print(e);
return;
}
throw "Expected exception.";
}
else {
f.call();
}
}