mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:27:17 +00:00
f41de20d46
Fixes https://github.com/dart-lang/sdk/issues/40765 Change-Id: If3b239c832c5137ad6999ab6e6ff3196bf54a6af Cq-Do-Not-Cancel-Tryjobs: true Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/137970 Commit-Queue: Aske Simon Christensen <askesc@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
43 lines
1 KiB
Dart
43 lines
1 KiB
Dart
// Copyright (c) 2020, 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.
|
|
|
|
class Something {
|
|
final int x;
|
|
Something({required this.x});
|
|
}
|
|
|
|
abstract class Base {
|
|
Something get x;
|
|
}
|
|
|
|
class Child1 extends Base {
|
|
final Something x;
|
|
Child1({required this.x});
|
|
}
|
|
|
|
class Child2 extends Base {
|
|
final int y;
|
|
final Something x;
|
|
Child2({required this.x, required this.y});
|
|
}
|
|
|
|
@pragma('vm:never-inline')
|
|
int foo(int k, Base x) {
|
|
var y = 0;
|
|
for (var i = 0; i < k; i++) {
|
|
x as Child1;
|
|
// Next line will be hoisted out as x.{Child1::x}.{Something::x}
|
|
// and at foo(0, Child2(..., y: 24)) will end up executing as
|
|
// x.{Child1::x} -> will load Child2::y (24) and then segfault.
|
|
y = x.x.x;
|
|
}
|
|
return y;
|
|
}
|
|
|
|
void main() {
|
|
print(foo(1, Child1(x: Something(x: 1))));
|
|
print(foo(1, Child1(x: Something(x: 2))));
|
|
print(foo(0, Child2(x: Something(x: 42), y: 24)));
|
|
}
|