diff --git a/pkg/analysis_server/analysis_server.iml b/pkg/analysis_server/analysis_server.iml index 93bf109e18d..2327b69d393 100644 --- a/pkg/analysis_server/analysis_server.iml +++ b/pkg/analysis_server/analysis_server.iml @@ -39,7 +39,6 @@ - diff --git a/pkg/analyzer_plugin/analyzer_plugin.iml b/pkg/analyzer_plugin/analyzer_plugin.iml index ad1d98e598c..29380be44f8 100644 --- a/pkg/analyzer_plugin/analyzer_plugin.iml +++ b/pkg/analyzer_plugin/analyzer_plugin.iml @@ -12,6 +12,9 @@ + + + @@ -21,6 +24,5 @@ - \ No newline at end of file diff --git a/pkg/front_end/lib/src/fasta/builder/ast_factory.dart b/pkg/front_end/lib/src/fasta/builder/ast_factory.dart index ec853d80e39..453281083a1 100644 --- a/pkg/front_end/lib/src/fasta/builder/ast_factory.dart +++ b/pkg/front_end/lib/src/fasta/builder/ast_factory.dart @@ -35,6 +35,10 @@ import 'package:kernel/ast.dart'; /// shadow-ify [DartType], since analyzer ASTs need to be able to record the /// exact tokens that were used to specify a type. abstract class AstFactory { + /// Creates an [Arguments] data structure. + Arguments arguments(List positional, + {List types, List named}); + /// Creates an `as` expression. AsExpression asExpression(Expression operand, Token operator, DartType type); @@ -132,6 +136,10 @@ abstract class AstFactory { /// Creates a return statement. Statement returnStatement(Expression expression, Token token); + /// Updates an [Arguments] data structure with the given generic [types]. + /// Should only be used when [types] were specified explicitly. + void setExplicitArgumentTypes(Arguments arguments, List types); + /// Creates a read of a static variable. StaticGet staticGet(Member readTarget, Token token); 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 22e7d3ea8f0..4ab3a43f6ad 100644 --- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart +++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart @@ -14,7 +14,7 @@ import '../parser/identifier_context.dart' show IdentifierContext; import 'package:front_end/src/fasta/builder/ast_factory.dart' show AstFactory; import 'package:front_end/src/fasta/kernel/kernel_shadow_ast.dart' - show KernelField; + show KernelArguments, KernelField; import 'package:front_end/src/fasta/kernel/utils.dart' show offsetForToken; @@ -567,9 +567,9 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { arguments.getRange(0, firstNamedArgumentIndex)); List named = new List.from( arguments.getRange(firstNamedArgumentIndex, arguments.length)); - push(new Arguments(positional, named: named)); + push(astFactory.arguments(positional, named: named)); } else { - push(new Arguments(arguments)); + push(astFactory.arguments(arguments)); } } @@ -783,7 +783,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { coreTypes.getClass("dart:core", "NoSuchMethodError").constructors.first; return new Throw(new ConstructorInvocation( constructor, - new Arguments([ + astFactory.arguments([ astFactory.nullLiteral(null), new SymbolLiteral(name), new ListLiteral(arguments.positional), @@ -1932,7 +1932,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { void endNewExpression(Token token) { debugEvent("NewExpression"); Token nameToken = token.next; - Arguments arguments = pop(); + KernelArguments arguments = pop(); String name = pop(); List typeArguments = pop(); var type = pop(); @@ -1945,7 +1945,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { if (typeArguments != null) { assert(arguments.types.isEmpty); - arguments.types.addAll(typeArguments); + astFactory.setExplicitArgumentTypes(arguments, typeArguments); } String errorName; @@ -2545,7 +2545,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { String message = formatUnexpected(uri, charOffset, error); Builder constructor = library.loader.getCompileTimeError(); return new Throw(buildStaticInvocation(constructor.target, - new Arguments([new StringLiteral(message)]))); + astFactory.arguments([new StringLiteral(message)]))); } Expression buildAbstractClassInstantiationError(String className, @@ -2554,7 +2554,7 @@ class BodyBuilder extends ScopeListener implements BuilderHelper { charOffset); Builder constructor = library.loader.getAbstractClassInstantiationError(); return new Throw(buildStaticInvocation(constructor.target, - new Arguments([new StringLiteral(className)]))); + astFactory.arguments([new StringLiteral(className)]))); } Statement buildCompileTimeErrorStatement(error, [int charOffset = -1]) { diff --git a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart index a884f2a58a7..b1b68cb9dea 100644 --- a/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart +++ b/pkg/front_end/lib/src/fasta/kernel/fasta_accessors.dart @@ -118,7 +118,8 @@ abstract class FastaAccessor implements Accessor { } Expression makeInvalidWrite(Expression value) { - return buildThrowNoSuchMethodError(new Arguments([value]), + return buildThrowNoSuchMethodError( + helper.astFactory.arguments([value]), isSetter: true); } @@ -209,7 +210,8 @@ abstract class ErrorAccessor implements FastaAccessor { @override Expression buildAssignment(Expression value, {bool voidContext: false}) { - return buildError(new Arguments([value]), isSetter: true); + return buildError(helper.astFactory.arguments([value]), + isSetter: true); } @override @@ -217,7 +219,8 @@ abstract class ErrorAccessor implements FastaAccessor { {int offset: TreeNode.noOffset, bool voidContext: false, Procedure interfaceTarget}) { - return buildError(new Arguments([value]), isGetter: true); + return buildError(helper.astFactory.arguments([value]), + isGetter: true); } @override @@ -225,7 +228,8 @@ abstract class ErrorAccessor implements FastaAccessor { {int offset: TreeNode.noOffset, bool voidContext: false, Procedure interfaceTarget}) { - return buildError(new Arguments([new IntLiteral(1)]), + return buildError( + helper.astFactory.arguments([new IntLiteral(1)]), isGetter: true); } @@ -234,14 +238,16 @@ abstract class ErrorAccessor implements FastaAccessor { {int offset: TreeNode.noOffset, bool voidContext: false, Procedure interfaceTarget}) { - return buildError(new Arguments([new IntLiteral(1)]), + return buildError( + helper.astFactory.arguments([new IntLiteral(1)]), isGetter: true); } @override Expression buildNullAwareAssignment(Expression value, DartType type, {bool voidContext: false}) { - return buildError(new Arguments([value]), isSetter: true); + return buildError(helper.astFactory.arguments([value]), + isSetter: true); } @override @@ -254,7 +260,8 @@ abstract class ErrorAccessor implements FastaAccessor { @override Expression makeInvalidWrite(Expression value) { - return buildError(new Arguments([value]), isSetter: true); + return buildError(helper.astFactory.arguments([value]), + isSetter: true); } } diff --git a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart index 51027e42dd3..e120f38520a 100644 --- a/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart +++ b/pkg/front_end/lib/src/fasta/kernel/frontend_accessors.dart @@ -321,14 +321,14 @@ class IndexAccessor extends Accessor { this.getter, this.setter, Token token) : super(helper, token); - Expression _makeSimpleRead() => helper.astFactory.methodInvocation( - receiver, indexGetName, new Arguments([index]), getter) + Expression _makeSimpleRead() => helper.astFactory.methodInvocation(receiver, + indexGetName, helper.astFactory.arguments([index]), getter) ..fileOffset = offsetForToken(token); Expression _makeSimpleWrite(Expression value, bool voidContext) { if (!voidContext) return _makeWriteAndReturn(value); return helper.astFactory.methodInvocation(receiver, indexSetName, - new Arguments([index, value]), setter) + helper.astFactory.arguments([index, value]), setter) ..fileOffset = offsetForToken(token); } @@ -346,15 +346,18 @@ class IndexAccessor extends Accessor { } Expression _makeRead() { - return builtGetter = helper.astFactory.methodInvocation(receiverAccess(), - indexGetName, new Arguments([indexAccess()]), getter) + return builtGetter = helper.astFactory.methodInvocation( + receiverAccess(), + indexGetName, + helper.astFactory.arguments([indexAccess()]), + getter) ..fileOffset = offsetForToken(token); } Expression _makeWrite(Expression value, bool voidContext) { if (!voidContext) return _makeWriteAndReturn(value); return helper.astFactory.methodInvocation(receiverAccess(), indexSetName, - new Arguments([indexAccess(), value]), setter) + helper.astFactory.arguments([indexAccess(), value]), setter) ..fileOffset = offsetForToken(token); } @@ -368,7 +371,7 @@ class IndexAccessor extends Accessor { .methodInvocation( receiverAccess(), indexSetName, - new Arguments( + helper.astFactory.arguments( [indexAccess(), new VariableGet(valueVariable)]), setter) ..fileOffset = offsetForToken(token)); @@ -394,13 +397,16 @@ class ThisIndexAccessor extends Accessor { Expression _makeSimpleRead() { return helper.astFactory.methodInvocation(new ThisExpression(), - indexGetName, new Arguments([index]), getter); + indexGetName, helper.astFactory.arguments([index]), getter); } Expression _makeSimpleWrite(Expression value, bool voidContext) { if (!voidContext) return _makeWriteAndReturn(value); - return helper.astFactory.methodInvocation(new ThisExpression(), - indexSetName, new Arguments([index, value]), setter); + return helper.astFactory.methodInvocation( + new ThisExpression(), + indexSetName, + helper.astFactory.arguments([index, value]), + setter); } indexAccess() { @@ -411,7 +417,7 @@ class ThisIndexAccessor extends Accessor { Expression _makeRead() => builtGetter = helper.astFactory.methodInvocation( new ThisExpression(), indexGetName, - new Arguments([indexAccess()]), + helper.astFactory.arguments([indexAccess()]), getter); Expression _makeWrite(Expression value, bool voidContext) { @@ -419,7 +425,7 @@ class ThisIndexAccessor extends Accessor { return helper.astFactory.methodInvocation( new ThisExpression(), indexSetName, - new Arguments([indexAccess(), value]), + helper.astFactory.arguments([indexAccess(), value]), setter); } @@ -429,7 +435,7 @@ class ThisIndexAccessor extends Accessor { .methodInvocation( new ThisExpression(), indexSetName, - new Arguments( + helper.astFactory.arguments( [indexAccess(), new VariableGet(valueVariable)]), setter)); return makeLet( @@ -454,30 +460,32 @@ class SuperIndexAccessor extends Accessor { } Expression _makeSimpleRead() => new SuperMethodInvocation( - indexGetName, new Arguments([index]), getter); + indexGetName, helper.astFactory.arguments([index]), getter); Expression _makeSimpleWrite(Expression value, bool voidContext) { if (!voidContext) return _makeWriteAndReturn(value); - return new SuperMethodInvocation( - indexSetName, new Arguments([index, value]), setter); + return new SuperMethodInvocation(indexSetName, + helper.astFactory.arguments([index, value]), setter); } Expression _makeRead() { - return builtGetter = new SuperMethodInvocation( - indexGetName, new Arguments([indexAccess()]), getter); + return builtGetter = new SuperMethodInvocation(indexGetName, + helper.astFactory.arguments([indexAccess()]), getter); } Expression _makeWrite(Expression value, bool voidContext) { if (!voidContext) return _makeWriteAndReturn(value); - return new SuperMethodInvocation(indexSetName, - new Arguments([indexAccess(), value]), setter); + return new SuperMethodInvocation( + indexSetName, + helper.astFactory.arguments([indexAccess(), value]), + setter); } _makeWriteAndReturn(Expression value) { var valueVariable = new VariableDeclaration.forValue(value); var dummy = new VariableDeclaration.forValue(new SuperMethodInvocation( indexSetName, - new Arguments( + helper.astFactory.arguments( [indexAccess(), new VariableGet(valueVariable)]), setter)); return makeLet( @@ -537,8 +545,8 @@ Expression makeLet(VariableDeclaration variable, Expression body) { Expression makeBinary(AstFactory astFactory, Expression left, Name operator, Procedure interfaceTarget, Expression right, {int offset: TreeNode.noOffset}) { - return astFactory.methodInvocation( - left, operator, new Arguments([right]), interfaceTarget) + return astFactory.methodInvocation(left, operator, + astFactory.arguments([right]), interfaceTarget) ..fileOffset = offset; } diff --git a/pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart b/pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart index d878af83726..6982553f7b2 100644 --- a/pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart +++ b/pkg/front_end/lib/src/fasta/kernel/kernel_ast_factory.dart @@ -12,6 +12,12 @@ import 'kernel_shadow_ast.dart'; /// Concrete implementation of [builder.AstFactory] for building a kernel AST. class KernelAstFactory implements AstFactory { + @override + Arguments arguments(List positional, + {List types, List named}) { + return new KernelArguments(positional, types: types, named: named); + } + @override AsExpression asExpression(Expression operand, Token operator, DartType type) { return new KernelAsExpression(operand, type) @@ -167,6 +173,11 @@ class KernelAstFactory implements AstFactory { ..fileOffset = offsetForToken(token); } + @override + void setExplicitArgumentTypes(Arguments arguments, List types) { + KernelArguments.setExplicitArgumentTypes(arguments, types); + } + @override StaticGet staticGet(Member readTarget, Token token) { return new KernelStaticGet(readTarget)..fileOffset = offsetForToken(token); 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 504c88a5fe7..6dc71000f3f 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 @@ -23,6 +23,23 @@ import 'package:front_end/src/fasta/type_inference/type_inferrer.dart'; import 'package:front_end/src/fasta/type_inference/type_promotion.dart'; import 'package:kernel/ast.dart'; +/// Concrete shadow object representing a set of invocation arguments. +class KernelArguments extends Arguments { + bool _hasExplicitTypeArguments; + + KernelArguments(List positional, + {List types, List named}) + : _hasExplicitTypeArguments = types != null && types.isNotEmpty, + super(positional, types: types, named: named); + + static void setExplicitArgumentTypes( + KernelArguments arguments, List types) { + arguments.types.clear(); + arguments.types.addAll(types); + arguments._hasExplicitTypeArguments = true; + } +} + /// Shadow object for [AsExpression]. class KernelAsExpression extends AsExpression implements KernelExpression { KernelAsExpression(Expression operand, DartType type) : super(operand, type); @@ -109,15 +126,16 @@ class KernelConstructorInvocation extends ConstructorInvocation @override DartType _inferExpression( KernelTypeInferrer inferrer, DartType typeContext, bool typeNeeded) { + KernelArguments arguments = this.arguments; return inferrer.inferConstructorInvocation( typeContext, typeNeeded, fileOffset, target, - arguments.types.isEmpty ? null : arguments.types, + arguments._hasExplicitTypeArguments ? arguments.types : null, _forEachArgument, (type) { - arguments = new Arguments(arguments.positional, - named: arguments.named, types: type.typeArguments); + arguments.types.clear(); + arguments.types.addAll(type.typeArguments); }); } } 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 b6b11317291..b8856021875 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 @@ -169,9 +169,12 @@ abstract class TypeInferrerImpl extends TypeInferrer { [], [], typeContext, - typesFromDownwardsInference); + typesFromDownwardsInference, + downwards: true); substitution = Substitution.fromPairs( targetTypeParameters, typesFromDownwardsInference); + formalTypes = []; + actualTypes = []; } else { inferredClassType = targetClass.rawType; } diff --git a/pkg/front_end/test/fasta/strong.status b/pkg/front_end/test/fasta/strong.status index 77399ceb74e..24f162c8492 100644 --- a/pkg/front_end/test/fasta/strong.status +++ b/pkg/front_end/test/fasta/strong.status @@ -76,7 +76,6 @@ inference/block_bodied_lambdas_no_return: Fail inference/block_bodied_lambdas_sync_star: Fail inference/circular_reference_via_closures: Fail inference/circular_reference_via_closures_initializer_types: Fail -inference/constructors_downwards_with_constraint: Fail inference/constructors_infer_from_arguments: Fail inference/constructors_infer_from_arguments_argument_not_assignable: Fail inference/constructors_infer_from_arguments_const: Fail @@ -84,9 +83,7 @@ inference/constructors_infer_from_arguments_const_with_upper_bound: Fail inference/constructors_infer_from_arguments_downwards_from_constructor: Fail inference/constructors_infer_from_arguments_factory: Fail inference/constructors_infer_from_arguments_factory_calls_constructor: Fail -inference/constructors_infer_from_arguments_named: Fail inference/constructors_infer_from_arguments_named_factory: Fail -inference/constructors_infer_from_arguments_redirecting: Fail inference/constructors_infer_from_arguments_redirecting_factory: Fail inference/constructors_inference_f_bounded: Fail inference/constructors_reverse_type_parameters: Fail @@ -101,10 +98,8 @@ inference/downwards_inference_inside_top_level: Fail inference/downwards_inference_on_function_arguments_infer_downwards: Fail inference/downwards_inference_on_function_expressions: Fail inference/downwards_inference_on_function_of_t_using_the_t: Fail -inference/downwards_inference_on_generic_constructor_arguments_empty_list: Fail inference/downwards_inference_on_generic_constructor_arguments_infer_downwards: Fail inference/downwards_inference_on_generic_function_expressions: Fail -inference/downwards_inference_on_instance_creations_infer_downwards: Fail inference/downwards_inference_on_list_literals_infer_downwards: Fail inference/downwards_inference_on_list_literals_infer_if_value_types_match_context: Fail inference/downwards_inference_on_map_literals: Fail @@ -177,7 +172,6 @@ inference/infer_statics_transitively_a: Fail inference/infer_throw: Fail inference/infer_type_on_var_from_field: Fail inference/infer_typed_map_literal: Fail -inference/infer_types_on_generic_instantiations_5: Fail inference/infer_types_on_loop_indices_for_each_loop: Fail inference/infer_types_on_loop_indices_for_loop_with_inference: Fail inference/infer_variable_void: Fail @@ -204,7 +198,6 @@ inference/inferred_type_via_closure_multiple_levels_of_nesting: Fail inference/inferred_type_via_closure_type_depends_on_args: Fail inference/inferred_type_via_closure_type_independent_of_args_field: Fail inference/inferred_type_via_closure_type_independent_of_args_top_level: Fail -inference/instantiate_to_bounds_invoke_constructor_no_bound: Fail inference/instantiate_to_bounds_invoke_constructor_type_args_exact: Fail inference/lambda_does_not_have_propagated_type_hint: Fail inference/list_literals_can_infer_null_top_level: Fail diff --git a/pkg/front_end/testcases/inference/constructors_downwards_with_constraint.dart.strong.expect b/pkg/front_end/testcases/inference/constructors_downwards_with_constraint.dart.strong.expect new file mode 100644 index 00000000000..de1f229f21b --- /dev/null +++ b/pkg/front_end/testcases/inference/constructors_downwards_with_constraint.dart.strong.expect @@ -0,0 +1,22 @@ +library test; +import self as self; +import "dart:core" as core; + +class A extends core::Object { + constructor •() → void + : super core::Object::•() + ; +} +class B extends self::A { + constructor •() → void + : super self::A::•() + ; +} +class Foo extends core::Object { + constructor •() → void + : super core::Object::•() + ; +} +static method main() → void { + self::Foo foo = new self::Foo::•(); +} diff --git a/pkg/front_end/testcases/inference/constructors_infer_from_arguments_named.dart.strong.expect b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_named.dart.strong.expect new file mode 100644 index 00000000000..9638bc30687 --- /dev/null +++ b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_named.dart.strong.expect @@ -0,0 +1,13 @@ +library test; +import self as self; +import "dart:core" as core; + +class C extends core::Object { + field self::C::T t = null; + constructor named(core::List t) → void + : super core::Object::•() + ; +} +static method main() → dynamic { + self::C x = new self::C::named([]); +} diff --git a/pkg/front_end/testcases/inference/constructors_infer_from_arguments_redirecting.dart.strong.expect b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_redirecting.dart.strong.expect new file mode 100644 index 00000000000..e3f0a553895 --- /dev/null +++ b/pkg/front_end/testcases/inference/constructors_infer_from_arguments_redirecting.dart.strong.expect @@ -0,0 +1,16 @@ +library test; +import self as self; +import "dart:core" as core; + +class C extends core::Object { + field self::C::T t; + constructor •(dynamic t) → void + : self::C::t = t, super core::Object::•() + ; + constructor named(core::List t) → void + : this self::C::•(t.[](0)) + ; +} +static method main() → dynamic { + self::C x = new self::C::named([42]); +} diff --git a/pkg/front_end/testcases/inference/downwards_inference_on_generic_constructor_arguments_empty_list.dart.strong.expect b/pkg/front_end/testcases/inference/downwards_inference_on_generic_constructor_arguments_empty_list.dart.strong.expect new file mode 100644 index 00000000000..8c1b5744265 --- /dev/null +++ b/pkg/front_end/testcases/inference/downwards_inference_on_generic_constructor_arguments_empty_list.dart.strong.expect @@ -0,0 +1,16 @@ +library test; +import self as self; +import "dart:core" as core; + +class F3 extends core::Object { + constructor •(core::Iterable> a) → void + : super core::Object::•() {} +} +class F4 extends core::Object { + constructor •({core::Iterable> a = null}) → void + : super core::Object::•() {} +} +static method main() → void { + new self::F3::•(>[]); + new self::F4::•(a: >[]); +} diff --git a/pkg/front_end/testcases/inference/downwards_inference_on_instance_creations_infer_downwards.dart.strong.expect b/pkg/front_end/testcases/inference/downwards_inference_on_instance_creations_infer_downwards.dart.strong.expect new file mode 100644 index 00000000000..147c9f7974f --- /dev/null +++ b/pkg/front_end/testcases/inference/downwards_inference_on_instance_creations_infer_downwards.dart.strong.expect @@ -0,0 +1,112 @@ +library test; +import self as self; +import "dart:core" as core; + +class A extends core::Object { + field self::A::S x; + field self::A::T y; + constructor •(dynamic x, dynamic y) → void + : self::A::x = x, self::A::y = y, super core::Object::•() + ; + constructor named(dynamic x, dynamic y) → void + : self::A::x = x, self::A::y = y, super core::Object::•() + ; +} +class B extends self::A { + constructor •(self::B::S y, self::B::T x) → void + : super self::A::•(x, y) + ; + constructor named(self::B::S y, self::B::T x) → void + : super self::A::named(x, y) + ; +} +class C extends self::B { + constructor •(self::C::S a) → void + : super self::B::•(a, a) + ; + constructor named(self::C::S a) → void + : super self::B::named(a, a) + ; +} +class D extends self::B { + constructor •(self::D::T a) → void + : super self::B::•(a, 3) + ; + constructor named(self::D::T a) → void + : super self::B::named(a, 3) + ; +} +class E extends self::A, self::E::T> { + constructor •(self::E::T a) → void + : super self::A::•(null, a) + ; +} +class F extends self::A { + constructor •(self::F::S x, self::F::T y, {core::List a = null, core::List b = null}) → void + : super self::A::•(x, y) + ; + constructor named(self::F::S x, self::F::T y, [self::F::S a = null, self::F::T b = null]) → void + : super self::A::•(a, b) + ; +} +static method main() → void { + { + self::A a0 = new self::A::•(3, "hello"); + self::A a1 = new self::A::named(3, "hello"); + self::A a2 = new self::A::•(3, "hello"); + self::A a3 = new self::A::named(3, "hello"); + self::A a4 = new self::A::•(3, "hello"); + self::A a5 = new self::A::named(3, "hello"); + } + { + self::A a0 = new self::A::•("hello", 3); + self::A a1 = new self::A::named("hello", 3); + } + { + self::A a0 = new self::B::•("hello", 3); + self::A a1 = new self::B::named("hello", 3); + self::A a2 = new self::B::•("hello", 3); + self::A a3 = new self::B::named("hello", 3); + self::A a4 = new self::B::•("hello", 3); + self::A a5 = new self::B::named("hello", 3); + } + { + self::A a0 = new self::B::•(3, "hello"); + self::A a1 = new self::B::named(3, "hello"); + } + { + self::A a0 = new self::C::•(3); + self::A a1 = new self::C::named(3); + self::A a2 = new self::C::•(3); + self::A a3 = new self::C::named(3); + self::A a4 = new self::C::•(3); + self::A a5 = new self::C::named(3); + } + { + self::A a0 = new self::C::•("hello"); + self::A a1 = new self::C::named("hello"); + } + { + self::A a0 = new self::D::•("hello"); + self::A a1 = new self::D::named("hello"); + self::A a2 = new self::D::•("hello"); + self::A a3 = new self::D::named("hello"); + self::A a4 = new self::D::•("hello"); + self::A a5 = new self::D::named("hello"); + } + { + self::A a0 = new self::D::•(3); + self::A a1 = new self::D::named(3); + } + { + self::A, core::String> a0 = new self::E::•("hello"); + } + { + self::A a0 = new self::F::•(3, "hello", a: [3], b: ["hello"]); + self::A a1 = new self::F::•(3, "hello", a: ["hello"], b: [3]); + self::A a2 = new self::F::named(3, "hello", 3, "hello"); + self::A a3 = new self::F::named(3, "hello"); + self::A a4 = new self::F::named(3, "hello", "hello", 3); + self::A a5 = new self::F::named(3, "hello", "hello"); + } +} diff --git a/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart b/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart index 7dbc105510b..f04bb947fef 100644 --- a/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart +++ b/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart @@ -30,3 +30,5 @@ foo() { .m(null, null); String z = new /*@typeArgs=dynamic*/ B().m(null, null); } + +main() {} diff --git a/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart.strong.expect b/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart.strong.expect new file mode 100644 index 00000000000..72d018aadff --- /dev/null +++ b/pkg/front_end/testcases/inference/infer_types_on_generic_instantiations_5.dart.strong.expect @@ -0,0 +1,35 @@ +library test; +import self as self; +import "dart:core" as core; + +abstract class I extends core::Object { + constructor •() → void + : super core::Object::•() + ; + abstract method m(dynamic a, dynamic f) → core::String; +} +abstract class A extends core::Object implements self::I { + const constructor •() → void + : super core::Object::•() + ; + abstract method m(dynamic a, dynamic f) → core::String; +} +abstract class M extends core::Object { + final field core::int y = 0; + constructor •() → void + : super core::Object::•() + ; +} +class B extends self::A implements self::M { + const constructor •() → void + : super self::A::•() + ; + get y() → core::int + return 0; + method m(dynamic a, dynamic f) → dynamic {} +} +static method foo() → dynamic { + core::int y = new self::B::•().m(null, null); + core::String z = new self::B::•().m(null, null); +} +static method main() → dynamic {} diff --git a/pkg/front_end/testcases/inference/instance_creation_downwards.dart b/pkg/front_end/testcases/inference/instance_creation_downwards.dart new file mode 100644 index 00000000000..f0669481a20 --- /dev/null +++ b/pkg/front_end/testcases/inference/instance_creation_downwards.dart @@ -0,0 +1,17 @@ +// 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 A { + A(B> b); +} + +class B {} + +main() { + var /*@type=A*/ x = + new /*@typeArgs=dynamic*/ A(new /*@typeArgs=List*/ B()); +} diff --git a/pkg/front_end/testcases/inference/instance_creation_downwards.dart.direct.expect b/pkg/front_end/testcases/inference/instance_creation_downwards.dart.direct.expect new file mode 100644 index 00000000000..3e4d4f72640 --- /dev/null +++ b/pkg/front_end/testcases/inference/instance_creation_downwards.dart.direct.expect @@ -0,0 +1,17 @@ +library test; +import self as self; +import "dart:core" as core; + +class A extends core::Object { + constructor •(self::B> b) → void + : super core::Object::•() + ; +} +class B extends core::Object { + constructor •() → void + : super core::Object::•() + ; +} +static method main() → dynamic { + dynamic x = new self::A::•(new self::B::•()); +} diff --git a/pkg/front_end/testcases/inference/instance_creation_downwards.dart.outline.expect b/pkg/front_end/testcases/inference/instance_creation_downwards.dart.outline.expect new file mode 100644 index 00000000000..aa9fb9489bc --- /dev/null +++ b/pkg/front_end/testcases/inference/instance_creation_downwards.dart.outline.expect @@ -0,0 +1,14 @@ +library test; +import self as self; +import "dart:core" as core; + +class A extends core::Object { + constructor •(self::B> b) → void + ; +} +class B extends core::Object { + constructor •() → void + ; +} +static method main() → dynamic + ; diff --git a/pkg/front_end/testcases/inference/instance_creation_downwards.dart.strong.expect b/pkg/front_end/testcases/inference/instance_creation_downwards.dart.strong.expect new file mode 100644 index 00000000000..0d8d78f07b4 --- /dev/null +++ b/pkg/front_end/testcases/inference/instance_creation_downwards.dart.strong.expect @@ -0,0 +1,17 @@ +library test; +import self as self; +import "dart:core" as core; + +class A extends core::Object { + constructor •(self::B> b) → void + : super core::Object::•() + ; +} +class B extends core::Object { + constructor •() → void + : super core::Object::•() + ; +} +static method main() → dynamic { + self::A x = new self::A::•(new self::B::•>()); +} diff --git a/pkg/front_end/testcases/inference/instantiate_to_bounds_invoke_constructor_no_bound.dart.strong.expect b/pkg/front_end/testcases/inference/instantiate_to_bounds_invoke_constructor_no_bound.dart.strong.expect new file mode 100644 index 00000000000..6a21f2ae8b2 --- /dev/null +++ b/pkg/front_end/testcases/inference/instantiate_to_bounds_invoke_constructor_no_bound.dart.strong.expect @@ -0,0 +1,12 @@ +library test; +import self as self; +import "dart:core" as core; + +class C extends core::Object { + constructor •() → void + : super core::Object::•() + ; +} +static method main() → dynamic { + self::C v = new self::C::•(); +}