dart-sdk/tests/language/extension_methods/static_extension_operator_override_error_test.dart
Paul Berry d4fb6b320c Set BinaryExpression.staticInvokeType properly for extension overrides.
Fixes #43114.

Bug: https://github.com/dart-lang/sdk/issues/43114
Change-Id: Ib0adf67c5ac5189732960a5925d7cdbcff0c4102
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/180441
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Paul Berry <paulberry@google.com>
2021-01-22 20:53:24 +00:00

24 lines
597 B
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.
/// Regression test for https://github.com/dart-lang/sdk/issues/43114.
class A {}
extension E on A {
String operator +(int other) => '';
}
f(A a, int b) {
int i = E(a) + b;
// ^^^^^^^^
// [analyzer] COMPILE_TIME_ERROR.INVALID_ASSIGNMENT
// ^
// [cfe] A value of type 'String' can't be assigned to a variable of type 'int'.
}
main() {
f(A(), 0);
}