From de312cd402f1db1a985fa8d5ee31db9178014136 Mon Sep 17 00:00:00 2001 From: "ngeoffray@google.com" Date: Wed, 13 Mar 2013 09:55:46 +0000 Subject: [PATCH] Fix bug 9090: provide the paramter checks arguments to the generative constructor body after the regular arguments. Review URL: https://codereview.chromium.org//12544021 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@19916 260f80e4-7a28-3924-810f-c04153c831b5 --- .../compiler/implementation/ssa/builder.dart | 10 +++++-- tests/language/argument_definition6_test.dart | 26 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/language/argument_definition6_test.dart diff --git a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart index 95197e6455a..c5188fcd1d0 100644 --- a/sdk/lib/_internal/compiler/implementation/ssa/builder.dart +++ b/sdk/lib/_internal/compiler/implementation/ssa/builder.dart @@ -1477,12 +1477,18 @@ class SsaBuilder extends ResolvedVisitor implements Visitor { FunctionSignature functionSignature = body.computeSignature(compiler); + // Provide the parameters to the generative constructor body. functionSignature.orderedForEachParameter((parameter) { - // if [parameter] is boxed, it will be a field in the box passed as the - // last parameter. So no need to direclty pass it. + // If [parameter] is boxed, it will be a field in the box passed as the + // last parameter. So no need to directly pass it. if (!localsHandler.isBoxed(parameter)) { bodyCallInputs.add(localsHandler.readLocal(parameter)); } + }); + + // Provide the parameter checks to the generative constructor + // body. + functionSignature.orderedForEachParameter((parameter) { // If [parameter] is checked, we pass the already computed // boolean to the constructor body. if (elements.isParameterChecked(parameter)) { diff --git a/tests/language/argument_definition6_test.dart b/tests/language/argument_definition6_test.dart new file mode 100644 index 00000000000..5dc87483ad9 --- /dev/null +++ b/tests/language/argument_definition6_test.dart @@ -0,0 +1,26 @@ +// Copyright (c) 2013, 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. + +// Regression test for +// https://code.google.com/p/dart/issues/detail?id=9090. +// Parameters used to be passed in the wrong order in a constructor in the +// presence of parameter checks. + + +class A { + A(expect1, expect2, value1, value2, {layers, serviceUrl}) { + Expect.equals(expect1, ?layers); + Expect.equals(expect2, ?serviceUrl); + Expect.equals(value1, layers); + Expect.equals(value2, serviceUrl); + } +} + +main() { + new A(false, false, null, null); + new A(true, false, 42, null, layers: 42); + new A(false, true, null, 43, serviceUrl: 43); + new A(true, true, 42, 43, layers: 42, serviceUrl: 43); + new A(true, true, 42, 43, serviceUrl: 43, layers: 42); +}