diff --git a/runtime/tests/vm/dart/regress_52449_test.dart b/runtime/tests/vm/dart/regress_52449_test.dart new file mode 100644 index 000000000000..b41340fc65bd --- /dev/null +++ b/runtime/tests/vm/dart/regress_52449_test.dart @@ -0,0 +1,27 @@ +// Copyright (c) 2023, 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. + +// Verifies that compiler doesn't crash when compiling +// implicit getter with unboxed return value. +// Regression test for https://github.com/dart-lang/sdk/issues/52449. + +abstract class A { + (int, int) get foo; +} + +class B implements A { + (int, int) get foo => (1, 2); +} + +class C implements A { + final (int, int) foo; + C(this.foo); +} + +void main() { + final list = [B(), C((3, 4))]; + for (var e in list) { + print(e.foo); + } +} diff --git a/runtime/vm/compiler/intrinsifier.cc b/runtime/vm/compiler/intrinsifier.cc index 2ed006cf569c..3a995e57a619 100644 --- a/runtime/vm/compiler/intrinsifier.cc +++ b/runtime/vm/compiler/intrinsifier.cc @@ -120,8 +120,9 @@ bool Intrinsifier::CanIntrinsifyFieldAccessor( } } else { // If the field is boxed, then we can either return the box directly or - // unbox it and return unboxed representation. - return true; + // unbox it and return unboxed representation (unless it is a record + // which requires a more sophisticated unboxing). + return !function.has_unboxed_record_return(); } } else { ASSERT(is_setter);