| library test /*isNonNullableByDefault*/; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/inference/bug31436_2.dart:23:36: Error: The argument type 'String' can't be assigned to the parameter type 'int'. |
| // . /*@target=List.add*/ add("hello"); // runtime error |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/bug31436_2.dart:28:12: Error: A value of type 'Object' can't be returned from a function with return type 'List<int>'. |
| // - 'Object' is from 'dart:core'. |
| // - 'List' is from 'dart:core'. |
| // return o; |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/bug31436_2.dart:52:36: Error: The argument type 'String' can't be assigned to the parameter type 'int'. |
| // . /*@target=List.add*/ add("hello"); // runtime error |
| // ^ |
| // |
| // pkg/front_end/testcases/inference/bug31436_2.dart:57:7: Error: A value of type 'Object' can't be returned from a function with return type 'List<int>'. |
| // - 'Object' is from 'dart:core'. |
| // - 'List' is from 'dart:core'. |
| // o; // No implicit downcast on the assignment, implicit downcast on the return |
| // ^ |
| // |
| import self as self; |
| import "dart:core" as core; |
| |
| static method block_test(() → core::List<core::Object> g) → void { |
| g = () → core::List<core::Object> { |
| return <core::Object>[3]; |
| }; |
| assert(g is{ForNonNullableByDefault} () → core::List<core::Object>); |
| assert(!(g is{ForNonNullableByDefault} () → core::List<core::int>)); |
| g(){() → core::List<core::Object>}.{core::List::add}("hello"){(core::Object) → void}; |
| core::List<core::int> l = <core::int>[3]; |
| g = () → core::List<core::int> { |
| return l; |
| }; |
| assert(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::Object>); |
| assert(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::int>); |
| try { |
| g{() → core::List<core::int>}(){() → core::List<core::int>}.{core::List::add}(invalid-expression "pkg/front_end/testcases/inference/bug31436_2.dart:23:36: Error: The argument type 'String' can't be assigned to the parameter type 'int'. |
| . /*@target=List.add*/ add(\"hello\"); // runtime error |
| ^" in "hello" as{TypeError,ForNonNullableByDefault} core::int){(core::int) → void}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError catch(no-exception-var) { |
| } |
| core::Object o = l; |
| g = () → core::List<core::int> { |
| return invalid-expression "pkg/front_end/testcases/inference/bug31436_2.dart:28:12: Error: A value of type 'Object' can't be returned from a function with return type 'List<int>'. |
| - 'Object' is from 'dart:core'. |
| - 'List' is from 'dart:core'. |
| return o; |
| ^" in o as{TypeError,ForNonNullableByDefault} core::List<core::int>; |
| }; |
| assert(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::Object>); |
| assert(!(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::int>)); |
| assert(!(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::Object)); |
| g{() → core::List<core::int>}(){() → core::List<core::int>}; |
| o = 3; |
| try { |
| g{() → core::List<core::int>}(){() → core::List<core::int>}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError catch(no-exception-var) { |
| } |
| } |
| static method arrow_test(() → core::List<core::Object> g) → void { |
| g = () → core::List<core::Object> => <core::Object>[3]; |
| assert(g is{ForNonNullableByDefault} () → core::List<core::Object>); |
| assert(!(g is{ForNonNullableByDefault} () → core::List<core::int>)); |
| g(){() → core::List<core::Object>}.{core::List::add}("hello"){(core::Object) → void}; |
| core::List<core::int> l = <core::int>[3]; |
| g = () → core::List<core::int> => l; |
| assert(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::Object>); |
| assert(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::int>); |
| try { |
| g{() → core::List<core::int>}(){() → core::List<core::int>}.{core::List::add}(invalid-expression "pkg/front_end/testcases/inference/bug31436_2.dart:52:36: Error: The argument type 'String' can't be assigned to the parameter type 'int'. |
| . /*@target=List.add*/ add(\"hello\"); // runtime error |
| ^" in "hello" as{TypeError,ForNonNullableByDefault} core::int){(core::int) → void}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError catch(no-exception-var) { |
| } |
| core::Object o = l; |
| g = () → core::List<core::int> => invalid-expression "pkg/front_end/testcases/inference/bug31436_2.dart:57:7: Error: A value of type 'Object' can't be returned from a function with return type 'List<int>'. |
| - 'Object' is from 'dart:core'. |
| - 'List' is from 'dart:core'. |
| o; // No implicit downcast on the assignment, implicit downcast on the return |
| ^" in o as{TypeError,ForNonNullableByDefault} core::List<core::int>; |
| assert(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::Object>); |
| assert(!(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::List<core::int>)); |
| assert(!(g{() → core::List<core::int>} is{ForNonNullableByDefault} () → core::Object)); |
| g{() → core::List<core::int>}(){() → core::List<core::int>}; |
| o = 3; |
| try { |
| g{() → core::List<core::int>}(){() → core::List<core::int>}; |
| throw "expected a runtime error"; |
| } |
| on core::TypeError catch(no-exception-var) { |
| } |
| } |