Files
sdk/tests/web/chained_incocation_test.dart
Nicholas Shahan 3f2801d63f [ddc] Avoid revisiting sub-expressions on chained invocations
Similar to https://dart-review.googlesource.com/c/sdk/+/445540 this
avoids compilation timeouts by avoiding recompiling the receiver in long
chains of invocations.

Guards all of the soundness checking behind a single generation check.
This was already true for nested calls but not for chains of invocations.

This also resolves a correctness issue where sub expressions of the
receiver in chained calls would be evaluated multiple times at runtime.

Change-Id: Iaf192a639e90d77995da55c7fa9c248e7bb93491
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/450183
Reviewed-by: Nate Biggs <natebiggs@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
2025-09-22 14:25:22 -07:00

43 lines
794 B
Dart

// Copyright (c) 2025, 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.
import "package:expect/expect.dart";
/// Regression test for some DDC timeouts while compiling when handling very
/// long chains of instance invocations.
void main() {
var fn = () => C()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.foo()
.bar()
.baz();
var x = fn();
Expect.equals(x, 10);
}
class C {
C foo() => C();
C bar() => C();
int baz() => 10;
}