mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 03:07:49 +00:00
41170b0a15
In strong mode, when a call to a super-initializer is reordered, we can use the static type of the super-initializer arguments to set the types of the temporary variables that we use to do the reordering. This is desirable because it might help avoid unnecessary casts. In non-strong mode, we use `dynamic` for the temporary variables, to replicate Dart 1.0 behavior. R=scheglov@google.com Review-Url: https://codereview.chromium.org/2993193002 .
40 lines
806 B
Dart
40 lines
806 B
Dart
// 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.
|
|
|
|
// This test verifies that super calls get reordered properly. It exercises the
|
|
// case where the arguments to super have a type other than `dynamic`.
|
|
String events = '';
|
|
|
|
int f(x) {
|
|
events += 'f($x)\n';
|
|
return 0;
|
|
}
|
|
|
|
String g(x) {
|
|
events += 'g($x)\n';
|
|
return 'foo';
|
|
}
|
|
|
|
class B {
|
|
num x;
|
|
String y;
|
|
B(this.x, this.y) {
|
|
events += 'super($x, $y)\n';
|
|
}
|
|
}
|
|
|
|
class C extends B {
|
|
final z;
|
|
C()
|
|
: super(f(1), g(2)),
|
|
z = f(3);
|
|
}
|
|
|
|
main() {
|
|
new C();
|
|
if (events != 'f(1)\ng(2)\nf(3)\nsuper(0, foo)\n') {
|
|
throw 'Unexpected sequence of events: $events';
|
|
}
|
|
}
|