diff --git a/pkg/front_end/lib/src/fasta/builder/field_builder.dart b/pkg/front_end/lib/src/fasta/builder/field_builder.dart index f8cfbc0e6f9..d5a37b6b5d1 100644 --- a/pkg/front_end/lib/src/fasta/builder/field_builder.dart +++ b/pkg/front_end/lib/src/fasta/builder/field_builder.dart @@ -6,6 +6,8 @@ library fasta.field_builder; import 'builder.dart' show LibraryBuilder, MemberBuilder; +import 'package:kernel/ast.dart' show DartType; + abstract class FieldBuilder extends MemberBuilder { final String name; @@ -15,6 +17,8 @@ abstract class FieldBuilder extends MemberBuilder { this.name, this.modifiers, LibraryBuilder compilationUnit, int charOffset) : super(compilationUnit, charOffset); + DartType get builtType; + void set initializer(T value); bool get isField => true; diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart index d8ebbd10e9f..a5efbc24008 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -366,6 +366,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { "Unhandled: '${field.name}' has more than one declaration."); } field.initializer = initializer; + _typeInferrer.inferFieldInitializer(field.builtType, initializer); } } pop(); // Type. diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart index 506c8858887..00e8811b8d9 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_field_builder.dart @@ -22,7 +22,7 @@ import 'package:front_end/src/fasta/source/source_library_builder.dart' import 'package:front_end/src/fasta/type_inference/type_inference_listener.dart' show TypeInferenceListener; -import 'package:kernel/ast.dart' show Expression, Field, Name; +import 'package:kernel/ast.dart' show DartType, Expression, Field, Name; import 'kernel_builder.dart' show Builder, FieldBuilder, KernelTypeBuilder, MetadataBuilder; @@ -94,4 +94,7 @@ class KernelFieldBuilder extends FieldBuilder { initializer = expression; } } + + @override + DartType get builtType => field.type; } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart index 6d7a19bc6f1..ba00e8dc54e 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart @@ -1070,14 +1070,14 @@ class KernelTypeInferenceEngine extends TypeInferenceEngineImpl { @override KernelTypeInferrer createLocalTypeInferrer( Uri uri, TypeInferenceListener listener) { - return new KernelTypeInferrer._(this, uri.toString(), listener); + return new KernelTypeInferrer._(this, uri.toString(), listener, false); } @override KernelTypeInferrer createTopLevelTypeInferrer( KernelField field, TypeInferenceListener listener) { return field._typeInferrer = - new KernelTypeInferrer._(this, getFieldUri(field), listener); + new KernelTypeInferrer._(this, getFieldUri(field), listener, true); } @override @@ -1128,8 +1128,8 @@ class KernelTypeInferrer extends TypeInferrerImpl { final typePromoter = new KernelTypePromoter(); KernelTypeInferrer._(KernelTypeInferenceEngine engine, String uri, - TypeInferenceListener listener) - : super(engine, uri, listener); + TypeInferenceListener listener, bool topLevel) + : super(engine, uri, listener, topLevel); @override Expression getFieldInitializer(KernelField field) { @@ -1165,7 +1165,7 @@ class KernelTypeInferrer extends TypeInferrerImpl { } @override - DartType inferFieldInitializer( + DartType inferFieldTopLevel( KernelField field, DartType type, bool typeNeeded) { return inferExpression(field.initializer, type, typeNeeded); } diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart index 2fcb7faa010..859d0491e7c 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_inference_engine.dart @@ -156,7 +156,7 @@ abstract class TypeInferenceEngineImpl extends TypeInferenceEngine { var typeInferrer = getFieldTypeInferrer(field); var type = getFieldDeclaredType(field); var inferredType = typeInferrer.inferDeclarationType( - typeInferrer.inferFieldInitializer(field, type, type == null)); + typeInferrer.inferFieldTopLevel(field, type, type == null)); if (type == null && strongMode && updateType) { instrumentation?.record( Uri.parse(typeInferrer.uri), diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart index 544a8aa9ffc..12bca4c8b86 100644 --- a/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart +++ b/pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart @@ -149,6 +149,9 @@ abstract class TypeInferrer { /// Gets the [FieldNode] corresponding to the given [readTarget], if any. FieldNode getFieldNodeForReadTarget(Member readTarget); + /// Performs full type inference on the given field initializer. + void inferFieldInitializer(DartType declaredType, Expression initializer); + /// Performs type inference on the given function body. void inferFunctionBody( DartType returnType, AsyncMarker asyncMarker, Statement body); @@ -187,11 +190,12 @@ abstract class TypeInferrerImpl extends TypeInferrer { /// inside a closure. ClosureContext closureContext; - TypeInferrerImpl(TypeInferenceEngineImpl engine, this.uri, this.listener) + TypeInferrerImpl( + TypeInferenceEngineImpl engine, this.uri, this.listener, bool topLevel) : coreTypes = engine.coreTypes, strongMode = engine.strongMode, classHierarchy = engine.classHierarchy, - instrumentation = engine.instrumentation, + instrumentation = topLevel ? null : engine.instrumentation, typeSchemaEnvironment = engine.typeSchemaEnvironment; /// Gets the type promoter that should be used to promote types during @@ -300,11 +304,17 @@ abstract class TypeInferrerImpl extends TypeInferrer { DartType inferExpression( Expression expression, DartType typeContext, bool typeNeeded); + @override + void inferFieldInitializer(DartType declaredType, Expression initializer) { + assert(closureContext == null); + inferExpression(initializer, declaredType, false); + } + /// Performs type inference on the given [field]'s initializer expression. /// /// Derived classes should provide an implementation that calls /// [inferExpression] for the given [field]'s initializer expression. - DartType inferFieldInitializer( + DartType inferFieldTopLevel( KernelField field, DartType type, bool typeNeeded); @override diff --git a/pkg/front_end/test/fasta/kompile.status b/pkg/front_end/test/fasta/kompile.status index 0b22b81033f..883c5fe350d 100644 --- a/pkg/front_end/test/fasta/kompile.status +++ b/pkg/front_end/test/fasta/kompile.status @@ -300,6 +300,7 @@ inference/simple_literal_int: Crash inference/simple_literal_null: Crash inference/static_method_tear_off: Crash inference/string_literal: Crash +inference/subexpressions_of_explicitly_typed_fields: Crash inference/top_level_return_and_yield: Crash inference/toplevel_inference_toplevel_var: Crash inference/type_cast: Crash diff --git a/pkg/front_end/testcases/inference/async_closure_return_type_flatten.dart.strong.expect b/pkg/front_end/testcases/inference/async_closure_return_type_flatten.dart.strong.expect index 68d859c9fcc..6295c18db51 100644 --- a/pkg/front_end/testcases/inference/async_closure_return_type_flatten.dart.strong.expect +++ b/pkg/front_end/testcases/inference/async_closure_return_type_flatten.dart.strong.expect @@ -4,10 +4,10 @@ import "dart:async" as asy; import "dart:core" as core; static field asy::Future futureInt = null; -static field () → asy::Future f = () → dynamic => self::futureInt; -static field () → asy::Future g = () → dynamic /* originally async */ { - final asy::Completer> :completer = asy::Completer::sync>(); - asy::FutureOr :return_value; +static field () → asy::Future f = () → asy::Future => self::futureInt; +static field () → asy::Future g = () → asy::Future /* originally async */ { + final asy::Completer> :completer = asy::Completer::sync>(); + asy::FutureOr :return_value; dynamic :async_op_then; dynamic :async_op_error; dynamic :await_jump_var = 0; diff --git a/pkg/front_end/testcases/inference/async_closure_return_type_future.dart.strong.expect b/pkg/front_end/testcases/inference/async_closure_return_type_future.dart.strong.expect index 2cf096d1d24..fab11ed6249 100644 --- a/pkg/front_end/testcases/inference/async_closure_return_type_future.dart.strong.expect +++ b/pkg/front_end/testcases/inference/async_closure_return_type_future.dart.strong.expect @@ -3,9 +3,9 @@ import self as self; import "dart:async" as asy; import "dart:core" as core; -static field () → asy::Future f = () → dynamic /* originally async */ { - final asy::Completer> :completer = asy::Completer::sync>(); - asy::FutureOr :return_value; +static field () → asy::Future f = () → asy::Future /* originally async */ { + final asy::Completer> :completer = asy::Completer::sync>(); + asy::FutureOr :return_value; dynamic :async_op_then; dynamic :async_op_error; dynamic :await_jump_var = 0; diff --git a/pkg/front_end/testcases/inference/async_closure_return_type_future_or.dart.strong.expect b/pkg/front_end/testcases/inference/async_closure_return_type_future_or.dart.strong.expect index afcab071d2c..64312b50c17 100644 --- a/pkg/front_end/testcases/inference/async_closure_return_type_future_or.dart.strong.expect +++ b/pkg/front_end/testcases/inference/async_closure_return_type_future_or.dart.strong.expect @@ -4,10 +4,10 @@ import "dart:async" as asy; import "dart:core" as core; static field asy::FutureOr futureOrInt = null; -static field () → asy::FutureOr f = () → dynamic => self::futureOrInt; -static field () → asy::Future g = () → dynamic /* originally async */ { - final asy::Completer> :completer = asy::Completer::sync>(); - asy::FutureOr :return_value; +static field () → asy::FutureOr f = () → asy::FutureOr => self::futureOrInt; +static field () → asy::Future g = () → asy::Future /* originally async */ { + final asy::Completer> :completer = asy::Completer::sync>(); + asy::FutureOr :return_value; dynamic :async_op_then; dynamic :async_op_error; dynamic :await_jump_var = 0; diff --git a/pkg/front_end/testcases/inference/infer_binary_custom.dart.strong.expect b/pkg/front_end/testcases/inference/infer_binary_custom.dart.strong.expect index c067a59554d..e1373c15749 100644 --- a/pkg/front_end/testcases/inference/infer_binary_custom.dart.strong.expect +++ b/pkg/front_end/testcases/inference/infer_binary_custom.dart.strong.expect @@ -11,8 +11,8 @@ class A extends core::Object { operator -(dynamic other) → core::double return 2.0; } -static field core::int v_add = new self::A::•().+("foo"); -static field core::double v_minus = new self::A::•().-("bar"); +static field core::int v_add = new self::A::•().{self::A::+}("foo"); +static field core::double v_minus = new self::A::•().{self::A::-}("bar"); static method main() → dynamic { self::v_add; self::v_minus; diff --git a/pkg/front_end/testcases/inference/infer_conditional.dart.strong.expect b/pkg/front_end/testcases/inference/infer_conditional.dart.strong.expect index e49a642746f..7b728812fdf 100644 --- a/pkg/front_end/testcases/inference/infer_conditional.dart.strong.expect +++ b/pkg/front_end/testcases/inference/infer_conditional.dart.strong.expect @@ -2,8 +2,8 @@ library test; import self as self; import "dart:core" as core; -static field core::num a = 1.==(2) ? 1 : 2.0; -static field core::num b = 1.==(2) ? 1.0 : 2; +static field core::num a = 1.{core::num::==}(2) ? 1 : 2.0; +static field core::num b = 1.{core::num::==}(2) ? 1.0 : 2; static method main() → dynamic { self::a; self::b; diff --git a/pkg/front_end/testcases/inference/infer_prefix_expression_custom.dart.strong.expect b/pkg/front_end/testcases/inference/infer_prefix_expression_custom.dart.strong.expect index e540a833a24..1fbb9c3ccf5 100644 --- a/pkg/front_end/testcases/inference/infer_prefix_expression_custom.dart.strong.expect +++ b/pkg/front_end/testcases/inference/infer_prefix_expression_custom.dart.strong.expect @@ -12,8 +12,8 @@ class A extends core::Object { return 2.0; } static field self::A a = new self::A::•(); -static field core::int v_complement = self::a.~(); -static field core::double v_negate = self::a.unary-(); +static field core::int v_complement = self::a.{self::A::~}(); +static field core::double v_negate = self::a.{self::A::unary-}(); static method main() → dynamic { self::a; self::v_complement; diff --git a/pkg/front_end/testcases/inference/infer_use_of_void.dart.strong.expect b/pkg/front_end/testcases/inference/infer_use_of_void.dart.strong.expect index 1ec9b60a072..b0d71fb7ce3 100644 --- a/pkg/front_end/testcases/inference/infer_use_of_void.dart.strong.expect +++ b/pkg/front_end/testcases/inference/infer_use_of_void.dart.strong.expect @@ -14,7 +14,7 @@ class C extends self::B { ; method f() → dynamic {} } -static field dynamic x = new self::C::•().f(); +static field dynamic x = new self::C::•().{self::C::f}(); static method main() → dynamic { self::x; } diff --git a/pkg/front_end/testcases/inference/inferred_type_custom_binary_op.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_custom_binary_op.dart.strong.expect index 8ed9b0922be..64fe5bbe2eb 100644 --- a/pkg/front_end/testcases/inference/inferred_type_custom_binary_op.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_custom_binary_op.dart.strong.expect @@ -10,7 +10,7 @@ class C extends core::Object { return true; } static field self::C c = new self::C::•(); -static field core::bool x = self::c.*(self::c); +static field core::bool x = self::c.{self::C::*}(self::c); static method main() → dynamic { self::c; self::x; diff --git a/pkg/front_end/testcases/inference/inferred_type_custom_binary_op_via_interface.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_custom_binary_op_via_interface.dart.strong.expect index 3d7052a64da..a6f7e415b8d 100644 --- a/pkg/front_end/testcases/inference/inferred_type_custom_binary_op_via_interface.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_custom_binary_op_via_interface.dart.strong.expect @@ -15,7 +15,7 @@ abstract class C extends core::Object implements self::I { ; } static field self::C c; -static field core::bool x = self::c.*(self::c); +static field core::bool x = self::c.{self::I::*}(self::c); static method main() → dynamic { self::c; } diff --git a/pkg/front_end/testcases/inference/inferred_type_custom_unary_op.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_custom_unary_op.dart.strong.expect index 618659ec5e5..202f2f36bfa 100644 --- a/pkg/front_end/testcases/inference/inferred_type_custom_unary_op.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_custom_unary_op.dart.strong.expect @@ -10,7 +10,7 @@ class C extends core::Object { return true; } static field self::C c = new self::C::•(); -static field core::bool x = self::c.unary-(); +static field core::bool x = self::c.{self::C::unary-}(); static method main() → dynamic { self::c; self::x; diff --git a/pkg/front_end/testcases/inference/inferred_type_custom_unary_op_via_interface.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_custom_unary_op_via_interface.dart.strong.expect index d1bfed5deb7..a00a9546ded 100644 --- a/pkg/front_end/testcases/inference/inferred_type_custom_unary_op_via_interface.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_custom_unary_op_via_interface.dart.strong.expect @@ -15,7 +15,7 @@ abstract class C extends core::Object implements self::I { ; } static field self::C c; -static field core::bool x = self::c.unary-(); +static field core::bool x = self::c.{self::I::unary-}(); static method main() → dynamic { self::c; } diff --git a/pkg/front_end/testcases/inference/inferred_type_invoke_method.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_invoke_method.dart.strong.expect index 548a7db22df..e1a3429071b 100644 --- a/pkg/front_end/testcases/inference/inferred_type_invoke_method.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_invoke_method.dart.strong.expect @@ -9,7 +9,7 @@ class C extends core::Object { method g() → core::bool return true; } -static field core::bool x = self::f().g(); +static field core::bool x = self::f().{self::C::g}(); static method f() → self::C return null; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/inferred_type_invoke_method_via_interface.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_invoke_method_via_interface.dart.strong.expect index 8a046f40e34..31e9fe838e3 100644 --- a/pkg/front_end/testcases/inference/inferred_type_invoke_method_via_interface.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_invoke_method_via_interface.dart.strong.expect @@ -14,7 +14,7 @@ abstract class C extends core::Object implements self::I { : super core::Object::•() ; } -static field core::bool x = self::f().g(); +static field core::bool x = self::f().{self::I::g}(); static method f() → self::C return null; static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type.dart.strong.expect index 69360d36dac..55d503c2b5f 100644 --- a/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field core::List<() → core::Object> v = [self::f, self::g]; +static field core::List<() → core::Object> v = <() → core::Object>[self::f, self::g]; static method f() → core::int return null; static method g() → core::String diff --git a/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_function_typed_param.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_function_typed_param.dart.strong.expect index 68baab9fa22..0472a60941f 100644 --- a/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_function_typed_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_function_typed_param.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field core::List<((core::String) → core::int) → core::Object> v = [self::f, self::g]; +static field core::List<((core::String) → core::int) → core::Object> v = <((core::String) → core::int) → core::Object>[self::f, self::g]; static method f((core::String) → core::int x) → core::int return null; static method g((core::String) → core::int x) → core::String diff --git a/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_required_param.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_required_param.dart.strong.expect index 9bfad930b20..8e9941b201a 100644 --- a/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_required_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_uses_synthetic_function_type_required_param.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field core::List<(core::int) → core::Object> v = [self::f, self::g]; +static field core::List<(core::int) → core::Object> v = <(core::int) → core::Object>[self::f, self::g]; static method f(core::int x) → core::int return null; static method g(core::int x) → core::String diff --git a/pkg/front_end/testcases/inference/inferred_type_via_closure_type_depends_on_args.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_via_closure_type_depends_on_args.dart.strong.expect index 4ac9d3d300d..db206c23410 100644 --- a/pkg/front_end/testcases/inference/inferred_type_via_closure_type_depends_on_args.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_via_closure_type_depends_on_args.dart.strong.expect @@ -3,7 +3,7 @@ import self as self; import "dart:core" as core; class C extends core::Object { - static final field (core::bool) → core::bool f = (core::bool b) → dynamic => b; + static final field (core::bool) → core::bool f = (core::bool b) → core::bool => b; constructor •() → void : super core::Object::•() ; diff --git a/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_field.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_field.dart.strong.expect index 74e45c59810..13f427c6632 100644 --- a/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_field.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_field.dart.strong.expect @@ -3,7 +3,7 @@ import self as self; import "dart:core" as core; class C extends core::Object { - static final field (core::bool) → core::int f = (core::bool b) → dynamic => 1; + static final field (core::bool) → core::int f = (core::bool b) → core::int => 1; constructor •() → void : super core::Object::•() ; diff --git a/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_top_level.dart.strong.expect b/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_top_level.dart.strong.expect index 7875bc47e38..a28ca70bead 100644 --- a/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_top_level.dart.strong.expect +++ b/pkg/front_end/testcases/inference/inferred_type_via_closure_type_independent_of_args_top_level.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static final field (core::bool) → core::int f = (core::bool b) → dynamic => 1; +static final field (core::bool) → core::int f = (core::bool b) → core::int => 1; static method main() → dynamic { self::f; } diff --git a/pkg/front_end/testcases/inference/list_literals_top_level.dart.strong.expect b/pkg/front_end/testcases/inference/list_literals_top_level.dart.strong.expect index 15c8f04c35e..37c4236b7ad 100644 --- a/pkg/front_end/testcases/inference/list_literals_top_level.dart.strong.expect +++ b/pkg/front_end/testcases/inference/list_literals_top_level.dart.strong.expect @@ -2,8 +2,8 @@ library test; import self as self; import "dart:core" as core; -static field core::List x1 = [1, 2, 3]; -static field core::List x2 = [1, 2.0, 3]; +static field core::List x1 = [1, 2, 3]; +static field core::List x2 = [1, 2.0, 3]; static method test1() → dynamic { self::x1.{core::List::add}("hi"); self::x1.{core::List::add}(4.0); diff --git a/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method.dart.strong.expect b/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method.dart.strong.expect index 0b4b1d68750..aafb666a703 100644 --- a/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method.dart.strong.expect +++ b/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method.dart.strong.expect @@ -14,5 +14,5 @@ class D extends core::Object { : super core::Object::•() ; } -static field self::D f = new self::C::•().f(); +static field self::D f = new self::C::•().{self::C::f}(); static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method_identifier_sequence.dart.strong.expect b/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method_identifier_sequence.dart.strong.expect index 2cee22509ba..ebcaa7dc2ff 100644 --- a/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method_identifier_sequence.dart.strong.expect +++ b/pkg/front_end/testcases/inference/method_call_with_type_arguments_instance_method_identifier_sequence.dart.strong.expect @@ -15,5 +15,5 @@ class D extends core::Object { ; } static field self::C c; -static field self::D f = self::c.f(); +static field self::D f = self::c.{self::C::f}(); static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart new file mode 100644 index 00000000000..38ba514bb88 --- /dev/null +++ b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart @@ -0,0 +1,14 @@ +// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +/*@testedFeatures=inference*/ +library test; + +class C { + List x = /*@typeArgs=num*/ [0]; +} + +List y = /*@typeArgs=num*/ [0]; + +main() {} diff --git a/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.direct.expect b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.direct.expect new file mode 100644 index 00000000000..f1293b6731e --- /dev/null +++ b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.direct.expect @@ -0,0 +1,12 @@ +library test; +import self as self; +import "dart:core" as core; + +class C extends core::Object { + field core::List x = [0]; + constructor •() → void + : super core::Object::•() + ; +} +static field core::List y = [0]; +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.outline.expect b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.outline.expect new file mode 100644 index 00000000000..81ff2d00258 --- /dev/null +++ b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.outline.expect @@ -0,0 +1,12 @@ +library test; +import self as self; +import "dart:core" as core; + +class C extends core::Object { + field core::List x; + constructor •() → void + ; +} +static field core::List y; +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.strong.expect b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.strong.expect new file mode 100644 index 00000000000..267f8bc9bf4 --- /dev/null +++ b/pkg/front_end/testcases/inference/subexpressions_of_explicitly_typed_fields.dart.strong.expect @@ -0,0 +1,12 @@ +library test; +import self as self; +import "dart:core" as core; + +class C extends core::Object { + field core::List x = [0]; + constructor •() → void + : super core::Object::•() + ; +} +static field core::List y = [0]; +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_dynamic_param.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_dynamic_param.dart.strong.expect index 281f03d86aa..e19dd93913b 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_dynamic_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_dynamic_param.dart.strong.expect @@ -7,7 +7,7 @@ class C extends core::Object { : super core::Object::•() ; } -static field self::C v = new self::C::•(() → dynamic { +static field self::C v = new self::C::•(() → core::int { return 1; }); static method main() → dynamic { diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_type_param.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_type_param.dart.strong.expect index cbe2f0ab078..cdef38d3f23 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_type_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_explicit_type_param.dart.strong.expect @@ -7,7 +7,7 @@ class C extends core::Object { : super core::Object::•() ; } -static field self::C v = new self::C::•(() → dynamic { +static field self::C v = new self::C::•(() → core::int { return 1; }); static method main() → dynamic { diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_no_type_param.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_no_type_param.dart.strong.expect index 74951c3c1d0..eee08a40632 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_no_type_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_constructor_call_no_type_param.dart.strong.expect @@ -7,7 +7,7 @@ class C extends core::Object { : super core::Object::•() ; } -static field self::C v = new self::C::•(() → dynamic { +static field self::C v = new self::C::•(() → core::int { return 1; }); static method main() → dynamic { diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param.dart.strong.expect index f6d3d93c015..757a8332ea9 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field core::List v = self::f(() → dynamic { +static field core::List v = self::f(() → core::int { return 1; }); static method f(() → self::f::T g) → core::List diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr2.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr2.dart.strong.expect index db7a7bdbe0e..0ddb217d3db 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr2.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_dynamic_param_via_expr2.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field dynamic v = self::f.call(() → dynamic { +static field dynamic v = self::f.call(() → core::int { return 1; }); static method f(() → self::f::T g) → core::List diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param.dart.strong.expect index dcf4f804ca7..4242dc9aad1 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field core::List v = self::f(() → dynamic { +static field core::List v = self::f(() → core::int { return 1; }); static method f(() → self::f::T g) → core::List diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr2.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr2.dart.strong.expect index db7a7bdbe0e..0ddb217d3db 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr2.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_function_call_explicit_type_param_via_expr2.dart.strong.expect @@ -2,7 +2,7 @@ library test; import self as self; import "dart:core" as core; -static field dynamic v = self::f.call(() → dynamic { +static field dynamic v = self::f.call(() → core::int { return 1; }); static method f(() → self::f::T g) → core::List diff --git a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_method_call_no_type_param.dart.strong.expect b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_method_call_no_type_param.dart.strong.expect index e0b5b4b78e0..9de7b958ac5 100644 --- a/pkg/front_end/testcases/inference/unsafe_block_closure_inference_method_call_no_type_param.dart.strong.expect +++ b/pkg/front_end/testcases/inference/unsafe_block_closure_inference_method_call_no_type_param.dart.strong.expect @@ -9,7 +9,7 @@ class C extends core::Object { method f(dynamic x) → core::double return 1.0; } -static field core::double v = new self::C::•().f(() → dynamic { +static field core::double v = new self::C::•().{self::C::f}(() → core::int { return 1; }); static method main() → dynamic {