blob: 07eaa2279f0fc4192cf0235546aa8bf83cccf689 [file] [log] [blame]
library test /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:14:65: Error: A value of type 'String Function<T>(String)' can't be assigned to a variable of type 'String Function<S>(int)'.
// v = /*error:INVALID_ASSIGNMENT*/ <T> /*@returnType=String*/ (String x) =>
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:16:76: Error: A value of type 'int' can't be returned from a function with return type 'String'.
// v = /*error:INVALID_ASSIGNMENT*/ <T> /*@returnType=String*/ (int x) => 3;
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:18: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_generic_function_expressions.dart:28:9: 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_generic_function_expressions.dart:30: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_generic_function_expressions.dart:33: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_generic_function_expressions.dart:43:71: Error: A value of type 'List<String> Function<T>(String)' can't be assigned to a variable of type 'List<String> Function<S>(int)'.
// - 'List' is from 'dart:core'.
// v = /*error:INVALID_ASSIGNMENT*/ <T> /*@returnType=List<String>*/ (String
// ^
//
// pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:46:54: 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_generic_function_expressions.dart:50: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_generic_function_expressions.dart:64:9: 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_generic_function_expressions.dart:66:10: 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;
static method test() void {
{
function f<S extends core::Object? = dynamic>(core::int x) core::String
return throw "";
<S extends core::Object? = dynamic>(core::int) core::String v = f;
v = <T extends core::Object? = dynamic>(core::int x) Never => throw "";
v = <T extends core::Object? = dynamic>(core::int x) core::String => "hello";
v = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:14:65: Error: A value of type 'String Function<T>(String)' can't be assigned to a variable of type 'String Function<S>(int)'.
v = /*error:INVALID_ASSIGNMENT*/ <T> /*@returnType=String*/ (String x) =>
^" in (<T extends core::Object? = dynamic>(core::String x) core::String => "hello") as{TypeError,ForNonNullableByDefault} <S extends core::Object? = dynamic>(core::int) core::String;
v = <T extends core::Object? = dynamic>(core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:16:76: Error: A value of type 'int' can't be returned from a function with return type 'String'.
v = /*error:INVALID_ASSIGNMENT*/ <T> /*@returnType=String*/ (int x) => 3;
^" in 3 as{TypeError,ForNonNullableByDefault} core::String;
v = <T extends core::Object? = dynamic>(core::int x) core::String {
return invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:18: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;
};
}
{
function f<S extends core::Object? = dynamic>(core::int x) core::String
return throw "";
<S extends core::Object? = dynamic>(core::int) core::String v = f;
v = <T extends core::Object? = dynamic>(core::int x) Never => throw "";
v = <T extends core::Object? = dynamic>(core::int x) core::String => "hello";
v = <T extends core::Object? = dynamic>(core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:28:9: 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;
v = <T extends core::Object? = dynamic>(core::int x) core::String {
return invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:30: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;
};
v = <T extends core::Object? = dynamic>(core::int x) core::String {
return invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:33: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;
};
}
{
function f<S extends core::Object? = dynamic>(core::int x) core::List<core::String>
return throw "";
<S extends core::Object? = dynamic>(core::int) core::List<core::String> v = f;
v = <T extends core::Object? = dynamic>(core::int x) Never => throw "";
v = <T extends core::Object? = dynamic>(core::int x) core::List<core::String> => core::_GrowableList::_literal1<core::String>("hello");
v = invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:43:71: Error: A value of type 'List<String> Function<T>(String)' can't be assigned to a variable of type 'List<String> Function<S>(int)'.
- 'List' is from 'dart:core'.
v = /*error:INVALID_ASSIGNMENT*/ <T> /*@returnType=List<String>*/ (String
^" in (<T extends core::Object? = dynamic>(core::String x) core::List<core::String> => core::_GrowableList::_literal1<core::String>("hello")) as{TypeError,ForNonNullableByDefault} <S extends core::Object? = dynamic>(core::int) core::List<core::String>;
v = <T extends core::Object? = dynamic>(core::int x) core::List<core::String> => core::_GrowableList::_literal1<core::String>(invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:46:54: 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);
v = <T extends core::Object? = dynamic>(core::int x) core::List<core::String> {
return core::_GrowableList::_literal1<core::String>(invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:50: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);
};
}
{
function int2int<S extends core::Object? = dynamic>(core::int x) core::int
return throw "";
function int2String<T extends core::Object? = dynamic>(core::int x) core::String
return throw "";
function string2String<T extends core::Object? = dynamic>(core::String x) core::String
return throw "";
<S extends core::Object? = dynamic>(core::int) core::int x = int2int;
x = <T extends core::Object? = dynamic>(core::int x) core::int => x;
x = <T extends core::Object? = dynamic>(core::int x) core::int => x.{core::num::+}(1){(core::num) core::int};
<T extends core::Object? = dynamic>(core::int) core::String y = int2String;
y = <T extends core::Object? = dynamic>(core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:64:9: 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;
y = <T extends core::Object? = dynamic>(core::int x) core::String => invalid-expression "pkg/front_end/testcases/inference/downwards_inference_on_generic_function_expressions.dart:66:10: 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);
<T extends core::Object? = dynamic>(core::String) core::String z = string2String;
z = <T extends core::Object? = dynamic>(core::String x) core::String => x.{core::String::substring}(3){(core::int, [core::int?]) core::String};
}
}
static method main() dynamic {}