Files
MarkZ c033dd24af [ddc] Updating tearoffs to be evaluated on access.
Tearoffs are now represented as a closure that resolves an underlying bound context and property on access. `_boundMethod` and RTI getters must also be evaluated late.

Additionally, we now both canonicalize static methods and tag them with their types at class-declaration time (though lazily) - so that late resolved closures have access to their types.

Some tests have been updated to expect simpler errors. DDC traditionally emits slightly different errors that might aid in debugging.

Change-Id: I1f762b8df45e0766d16dbc8688073768c8bfd233
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/401321
Reviewed-by: Nicholas Shahan <nshahan@google.com>
Commit-Queue: Mark Zhou <markzipan@google.com>
2025-01-08 13:40:33 -08:00

32 lines
861 B
Dart

// Copyright (c) 2024, 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';
import 'package:reload_test/reload_test_utils.dart';
// Adapted from:
// https://github.com/dart-lang/sdk/blob/f34a2ed99fc1b34cedbd974a5801f8d922121126/runtime/vm/isolate_reload_test.cc#L1618
class C {
foo() => 'old';
}
var c, f1, f2;
helper() {
c = new C();
f1 = c.foo;
}
Future<void> main() async {
helper();
await hotReload();
helper();
Expect.equals('new', f1());
Expect.equals('new', f2());
Expect.equals(f1, f2);
// We test that instance tearoffs are not identical to be consistent wih the
// VM. This behavior is not guaranteed by the spec.
Expect.notIdentical(f1, f2);
}