Files
sdk/pkg/front_end/testcases/patterns/issue51029.dart
T
Johnni Winther 924cf941e9 [cfe] Add test for issue 51029
Closes #51029

Change-Id: I7ee15c5e9cde19a323b4a2778c673017cac3795f
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/279714
Commit-Queue: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Chloe Stefantsova <cstefantsova@google.com>
2023-01-26 09:35:19 +00:00

39 lines
814 B
Dart

// 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.
class Square {
final void Function(String s)? logFunction;
final double length;
const Square(this.length, [this.logFunction = null]);
void _log(String toLog) {
void Function(String s)? _l = logFunction;
if (_l != null) {
_l(toLog);
}
}
double get area {
_log("Square.area");
return length * length;
}
}
String log = "";
void logger(String s) {
log += s;
}
main() {
var Square(area: _) = Square(2, logger);
expect("Square.area", log);
}
expect(expected, actual) {
if (expected != actual) {
throw 'Expected $expected, actual $actual';
}
}