blob: 325a143f887acdbe6dc934d783bcbcf7640dc462 [file] [log] [blame]
library test /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:15:66: Error: A value of type 'String Function(String)' can't be assigned to a variable of type 'String Function(int)'.
// l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ (String x) =>
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:18:77: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// l3 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ (int x) => 3;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:20:47: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// return /*error:RETURN_OF_INVALID_TYPE*/ 3;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:30:13: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// 3;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:32:47: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// return /*error:RETURN_OF_INVALID_TYPE*/ 3;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:35:47: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// return /*error:RETURN_OF_INVALID_TYPE*/ x;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:44:72: Error: A value of type 'List<String> Function(String)' can't be assigned to a variable of type 'List<String> Function(int)'.
// - 'List' is from 'dart:core'.
// l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ (String
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:48:58: Error: A value of type 'int' can't be assigned to a variable of type 'String'.
// /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:52:52: Error: A value of type 'int' can't be assigned to a variable of type 'String'.
// /*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:62:13: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// x;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:65:14: Error: The method 'substring' isn't defined for the class 'int'.
// Try correcting the name to the name of an existing method, or defining a method named 'substring'.
// .substring(3);
// ^^^^^^^^^
//
import self as self;
import "dart:core" as core;
typedef Function2<contravariant S extends core::Object? = dynamic, T extends core::Object? = dynamic> = (S%) T%;
static method test() void {
{
(core::int) core::String l0 = (core::int x) Never => throw "";
(core::int) core::String l1 = (core::int x) core::String => "hello";
(core::int) core::String l2 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:15:66: Error: A value of type 'String Function(String)' can't be assigned to a variable of type 'String Function(int)'.
l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ (String x) =>
^" in ((core::String x) core::String => "hello") as{TypeError,ForNonNullableByDefault} (core::int) core::String;
(core::int) core::String l3 = (core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:18:77: Error: A value of type 'int' can't be returned from a function with return type 'String'.
l3 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=String*/ (int x) => 3;
^" in 3 as{TypeError,ForNonNullableByDefault} core::String;
(core::int) core::String l4 = (core::int x) core::String {
return invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:20:47: Error: A value of type 'int' can't be returned from a function with return type 'String'.
return /*error:RETURN_OF_INVALID_TYPE*/ 3;
^" in 3 as{TypeError,ForNonNullableByDefault} core::String;
};
}
{
(core::int) core::String l0 = (core::int x) Never => throw "";
(core::int) core::String l1 = (core::int x) core::String => "hello";
(core::int) core::String l2 = (core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:30:13: Error: A value of type 'int' can't be returned from a function with return type 'String'.
3;
^" in 3 as{TypeError,ForNonNullableByDefault} core::String;
(core::int) core::String l3 = (core::int x) core::String {
return invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:32:47: Error: A value of type 'int' can't be returned from a function with return type 'String'.
return /*error:RETURN_OF_INVALID_TYPE*/ 3;
^" in 3 as{TypeError,ForNonNullableByDefault} core::String;
};
(core::int) core::String l4 = (core::int x) core::String {
return invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:35:47: Error: A value of type 'int' can't be returned from a function with return type 'String'.
return /*error:RETURN_OF_INVALID_TYPE*/ x;
^" in x as{TypeError,ForNonNullableByDefault} core::String;
};
}
{
(core::int) core::List<core::String> l0 = (core::int x) Never => throw "";
(core::int) core::List<core::String> l1 = (core::int x) core::List<core::String> => <core::String>["hello"];
(core::int) core::List<core::String> l2 = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:44:72: Error: A value of type 'List<String> Function(String)' can't be assigned to a variable of type 'List<String> Function(int)'.
- 'List' is from 'dart:core'.
l2 = /*error:INVALID_ASSIGNMENT*/ /*@returnType=List<String>*/ (String
^" in ((core::String x) core::List<core::String> => <core::String>["hello"]) as{TypeError,ForNonNullableByDefault} (core::int) core::List<core::String>;
(core::int) core::List<core::String> l3 = (core::int x) core::List<core::String> => <core::String>[invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:48:58: Error: A value of type 'int' can't be assigned to a variable of type 'String'.
/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
^" in 3 as{TypeError,ForNonNullableByDefault} core::String];
(core::int) core::List<core::String> l4 = (core::int x) core::List<core::String> {
return <core::String>[invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:52:52: Error: A value of type 'int' can't be assigned to a variable of type 'String'.
/*error:LIST_ELEMENT_TYPE_NOT_ASSIGNABLE*/ 3
^" in 3 as{TypeError,ForNonNullableByDefault} core::String];
};
}
{
(core::int) core::int l0 = (core::int x) core::int => x;
(core::int) core::int l1 = (core::int x) core::int => x.{core::num::+}(1){(core::num) core::int};
(core::int) core::String l2 = (core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:62:13: Error: A value of type 'int' can't be returned from a function with return type 'String'.
x;
^" in x as{TypeError,ForNonNullableByDefault} core::String;
(core::int) core::String l3 = (core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_function_expressions.dart:65:14: Error: The method 'substring' isn't defined for the class 'int'.
Try correcting the name to the name of an existing method, or defining a method named 'substring'.
.substring(3);
^^^^^^^^^" in x{<unresolved>}.substring(3) as{TypeError,ForDynamic,ForNonNullableByDefault} core::String;
(core::String) core::String l4 = (core::String x) core::String => x.{core::String::substring}(3){(core::int, [core::int?]) core::String};
}
}
static method main() dynamic {}