blob: 226752afd35334b13085b6594a534c3b2cec0328 [file] [log] [blame]
library test /*isLegacy*/;
//
// Problems in library:
//
// pkg/front_end/testcases/inference/bug31436.dart:5:1: Error: Library doesn't support null safety.
// // @dart=2.9
// ^^^^^^^^^^^^
//
import self as self;
import "dart:core" as core;
static method block_test() void {
() →* core::List<core::Object*>* g;
g = () core::List<core::Object*>* {
return core::_GrowableList::_literal1<core::Object*>(3);
};
assert(g is{ForLegacy} () →* core::List<core::Object*>*);
assert(!(g is{ForLegacy} () →* core::List<core::int*>*));
g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void};
core::List<core::int*>* l = core::_GrowableList::_literal1<core::int*>(3);
g = () core::List<core::int*>* {
return l;
};
assert(g is{ForLegacy} () →* core::List<core::Object*>*);
assert(g is{ForLegacy} () →* core::List<core::int*>*);
try {
g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void};
throw "expected a runtime error";
}
on core::TypeError* catch(no-exception-var) {
}
core::Object* o = l;
g = () core::List<core::Object*>* {
return o as{TypeError,ForLegacy} core::List<core::Object*>*;
};
assert(g is{ForLegacy} () →* core::List<core::Object*>*);
assert(!(g is{ForLegacy} () →* core::List<core::int*>*));
assert(!(g is{ForLegacy} () →* core::Object*));
g(){() →* core::List<core::Object*>*};
o = 3;
try {
g(){() →* core::List<core::Object*>*};
throw "expected a runtime error";
}
on core::TypeError* catch(no-exception-var) {
}
}
static method arrow_test() void {
() →* core::List<core::Object*>* g;
g = () core::List<core::Object*>* => core::_GrowableList::_literal1<core::Object*>(3);
assert(g is{ForLegacy} () →* core::List<core::Object*>*);
assert(!(g is{ForLegacy} () →* core::List<core::int*>*));
g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void};
core::List<core::int*>* l = core::_GrowableList::_literal1<core::int*>(3);
g = () core::List<core::int*>* => l;
assert(g is{ForLegacy} () →* core::List<core::Object*>*);
assert(g is{ForLegacy} () →* core::List<core::int*>*);
try {
g(){() →* core::List<core::Object*>*}.{core::List::add}("hello"){(core::Object*) →* void};
throw "expected a runtime error";
}
on core::TypeError* catch(no-exception-var) {
}
core::Object* o = l;
g = () core::List<core::Object*>* => o as{TypeError,ForLegacy} core::List<core::Object*>*;
assert(g is{ForLegacy} () →* core::List<core::Object*>*);
assert(!(g is{ForLegacy} () →* core::List<core::int*>*));
assert(!(g is{ForLegacy} () →* core::Object*));
g(){() →* core::List<core::Object*>*};
o = 3;
try {
g(){() →* core::List<core::Object*>*};
throw "expected a runtime error";
}
on core::TypeError* catch(no-exception-var) {
}
}
static method main() dynamic {
self::block_test();
self::arrow_test();
}