[CFE] Better error messages on errors with user definable operators

Fixes #36383

Change-Id: I24fd51bdb3ead75973009fe515819f9c8354e1b0
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98332
Commit-Queue: Jens Johansen <jensj@google.com>
Reviewed-by: Kevin Millikin <kmillikin@google.com>
diff --git a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
index 2a9f6e4..828f7a4 100644
--- a/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
+++ b/pkg/front_end/lib/src/fasta/fasta_codes_generated.dart
@@ -7208,6 +7208,27 @@
     message: r"""Can't assign to this.""");
 
 // DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Template<Message Function(Token token)> templateNotBinaryOperator =
+    const Template<Message Function(Token token)>(
+        messageTemplate: r"""'#lexeme' isn't a binary operator.""",
+        withArguments: _withArgumentsNotBinaryOperator);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+const Code<Message Function(Token token)> codeNotBinaryOperator =
+    const Code<Message Function(Token token)>(
+  "NotBinaryOperator",
+  templateNotBinaryOperator,
+);
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
+Message _withArgumentsNotBinaryOperator(Token token) {
+  String lexeme = token.lexeme;
+  return new Message(codeNotBinaryOperator,
+      message: """'${lexeme}' isn't a binary operator.""",
+      arguments: {'token': token});
+}
+
+// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
 const Template<Message Function(String string)> templateNotConstantExpression =
     const Template<Message Function(String string)>(
         messageTemplate: r"""#string is not a constant expression.""",
diff --git a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
index c49a9f9..203386b 100644
--- a/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
+++ b/pkg/front_end/lib/src/fasta/kernel/body_builder.dart
@@ -45,7 +45,8 @@
 
 import '../scanner.dart' show Token;
 
-import '../scanner/token.dart' show isBinaryOperator, isMinusOperator;
+import '../scanner/token.dart'
+    show isBinaryOperator, isMinusOperator, isUserDefinableOperator;
 
 import '../scope.dart' show ProblemBuilder;
 
@@ -1383,8 +1384,15 @@
       negate = true;
     }
     if (!isBinaryOperator(operator) && !isMinusOperator(operator)) {
-      return buildProblem(fasta.templateInvalidOperator.withArguments(token),
-          token.charOffset, token.length);
+      if (isUserDefinableOperator(operator)) {
+        return buildProblem(
+            fasta.templateNotBinaryOperator.withArguments(token),
+            token.charOffset,
+            token.length);
+      } else {
+        return buildProblem(fasta.templateInvalidOperator.withArguments(token),
+            token.charOffset, token.length);
+      }
     } else {
       Expression result = buildMethodInvocation(a, new Name(operator),
           forest.arguments(<Expression>[b], noLocation), token.charOffset,
diff --git a/pkg/front_end/messages.status b/pkg/front_end/messages.status
index a522fea..5a1995a 100644
--- a/pkg/front_end/messages.status
+++ b/pkg/front_end/messages.status
@@ -292,6 +292,7 @@
 NotAConstantExpression/example: Fail
 NotAType/example: Fail
 NotAnLvalue/example: Fail
+NotBinaryOperator/analyzerCode: Fail
 NotConstantExpression/example: Fail
 OperatorMinusParameterMismatch/example: Fail
 OperatorParameterMismatch0/analyzerCode: Fail
diff --git a/pkg/front_end/messages.yaml b/pkg/front_end/messages.yaml
index 34f3c6f..558bd5b 100644
--- a/pkg/front_end/messages.yaml
+++ b/pkg/front_end/messages.yaml
@@ -2476,6 +2476,16 @@
   script:
     - "class C { void operator %=(x) {} }"
 
+NotBinaryOperator:
+  template: "'#lexeme' isn't a binary operator."
+  script: >
+    class C { operator~() { return null; } }
+
+    main() {
+      C c = new C();
+      print(c ~ 2);
+    }
+
 OperatorParameterMismatch0:
   template: "Operator '#name' shouldn't have any parameters."
 
diff --git a/pkg/front_end/testcases/legacy.status b/pkg/front_end/testcases/legacy.status
index 1d9a60c..2489f9f 100644
--- a/pkg/front_end/testcases/legacy.status
+++ b/pkg/front_end/testcases/legacy.status
@@ -36,6 +36,7 @@
 micro: Fail # External method marked abstract.
 minimum_int: Crash # Min int literal not supported in non-strong mode.
 named_parameters: Fail # Missing types and unnecessary default values.
+operator_method_not_found: RuntimeError # Expected
 optional: Fail # Unnecessary default values.
 rasta/abstract_constructor: Fail
 rasta/bad_constructor_redirection: Fail
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart b/pkg/front_end/testcases/operator_method_not_found.dart
new file mode 100644
index 0000000..c54c358
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart
@@ -0,0 +1,55 @@
+// Copyright (c) 2019, 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 Foo {
+}
+
+main() {
+  Foo foo = new Foo();
+
+  // Not defined, but given right arity.
+  print(foo < 2);
+  print(foo > 2);
+  print(foo <= 2);
+  print(foo >= 2);
+  print(foo == 2);
+  print(foo - 2);
+  print(foo + 2);
+  print(foo / 2);
+  print(foo ~/ 2);
+  print(foo * 2);
+  print(foo % 2);
+  print(foo | 2);
+  print(foo ^ 2);
+  print(foo & 2);
+  print(foo << 2);
+  print(foo >> 2);
+  // print(foo >>> 2); // triple shift not enabled by default at the moment.
+  print(foo[2] = 2);
+  print(foo[2]);
+  print(~foo);
+  print(-foo);
+
+  // Not defined, and given wrong arity.
+  // Should be binary.
+  print(<foo);
+  print(>foo);
+  print(<=foo);
+  print(>=foo);
+  print(==foo);
+  print(+foo);
+  print(/foo);
+  print(~/foo);
+  print(*foo);
+  print(%foo);
+  print(|foo);
+  print(^foo);
+  print(&foo);
+  print(<<foo);
+  print(>>foo);
+  // print(>>>foo); // triple shift not enabled by default at the moment.
+
+  // Should be unary.
+  print(foo ~ 2);
+}
\ No newline at end of file
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart.hierarchy.expect b/pkg/front_end/testcases/operator_method_not_found.dart.hierarchy.expect
new file mode 100644
index 0000000..6dc6110
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart.hierarchy.expect
@@ -0,0 +1,36 @@
+Object:
+  superclasses:
+  interfaces:
+  classMembers:
+    Object._haveSameRuntimeType
+    Object.toString
+    Object.runtimeType
+    Object._toString
+    Object._simpleInstanceOf
+    Object._hashCodeRnd
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._objectHashCode
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
+
+Foo:
+  superclasses:
+    Object
+  interfaces:
+  classMembers:
+    Object.toString
+    Object.runtimeType
+    Object._simpleInstanceOf
+    Object._instanceOf
+    Object.noSuchMethod
+    Object._identityHashCode
+    Object.hashCode
+    Object._simpleInstanceOfFalse
+    Object._simpleInstanceOfTrue
+    Object.==
+  classSetters:
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart.legacy.expect b/pkg/front_end/testcases/operator_method_not_found.dart.legacy.expect
new file mode 100644
index 0000000..0abf9ef
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart.legacy.expect
@@ -0,0 +1,154 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Error: Expected '>' after this.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:13: Error: Expected '[' before this.
+//   print(<foo);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Warning: 'foo' isn't a type.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: Expected an identifier, but got '>'.
+//   print(>foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: Expected an identifier, but got '<='.
+//   print(<=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: Expected an identifier, but got '>='.
+//   print(>=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: Expected an identifier, but got '=='.
+//   print(==foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: '+' is not a prefix operator.
+// Try removing '+'.
+//   print(+foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: Expected an identifier, but got '/'.
+//   print(/foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: Expected an identifier, but got '~/'.
+//   print(~/foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: Expected an identifier, but got '*'.
+//   print(*foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: Expected an identifier, but got '%'.
+//   print(%foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: Expected an identifier, but got '|'.
+//   print(|foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: Expected an identifier, but got '^'.
+//   print(^foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: Expected an identifier, but got '&'.
+//   print(&foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: Expected an identifier, but got '<<'.
+//   print(<<foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: Expected an identifier, but got '>>'.
+//   print(>>foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+//   print(foo ~ 2);
+//             ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+  synthetic constructor •() → self::Foo
+    : super core::Object::•()
+    ;
+}
+static method main() → dynamic {
+  self::Foo foo = new self::Foo::•();
+  core::print(foo.<(2));
+  core::print(foo.>(2));
+  core::print(foo.<=(2));
+  core::print(foo.>=(2));
+  core::print(foo.==(2));
+  core::print(foo.-(2));
+  core::print(foo.+(2));
+  core::print(foo./(2));
+  core::print(foo.~/(2));
+  core::print(foo.*(2));
+  core::print(foo.%(2));
+  core::print(foo.|(2));
+  core::print(foo.^(2));
+  core::print(foo.&(2));
+  core::print(foo.<<(2));
+  core::print(foo.>>(2));
+  core::print(let final dynamic #t1 = foo in let final dynamic #t2 = 2 in let final dynamic #t3 = 2 in let final dynamic #t4 = #t1.[]=(#t2, #t3) in #t3);
+  core::print(foo.[](2));
+  core::print(foo.~());
+  core::print(foo.unary-());
+  core::print(<invalid-type>[]);
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: This couldn't be parsed.
+  print(>foo);
+        ^".>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: This couldn't be parsed.
+  print(<=foo);
+        ^".<=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: This couldn't be parsed.
+  print(>=foo);
+        ^".>=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: This couldn't be parsed.
+  print(==foo);
+        ^".==(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: This couldn't be parsed.
+  print(+foo);
+        ^".+(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: This couldn't be parsed.
+  print(/foo);
+        ^"./(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: This couldn't be parsed.
+  print(~/foo);
+        ^".~/(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: This couldn't be parsed.
+  print(*foo);
+        ^".*(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: This couldn't be parsed.
+  print(%foo);
+        ^".%(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: This couldn't be parsed.
+  print(|foo);
+        ^".|(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: This couldn't be parsed.
+  print(^foo);
+        ^".^(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: This couldn't be parsed.
+  print(&foo);
+        ^".&(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: This couldn't be parsed.
+  print(<<foo);
+        ^".<<(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: This couldn't be parsed.
+  print(>>foo);
+        ^".>>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+  print(foo ~ 2);
+            ^");
+}
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart.legacy.transformed.expect b/pkg/front_end/testcases/operator_method_not_found.dart.legacy.transformed.expect
new file mode 100644
index 0000000..0abf9ef
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart.legacy.transformed.expect
@@ -0,0 +1,154 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Error: Expected '>' after this.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:13: Error: Expected '[' before this.
+//   print(<foo);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Warning: 'foo' isn't a type.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: Expected an identifier, but got '>'.
+//   print(>foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: Expected an identifier, but got '<='.
+//   print(<=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: Expected an identifier, but got '>='.
+//   print(>=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: Expected an identifier, but got '=='.
+//   print(==foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: '+' is not a prefix operator.
+// Try removing '+'.
+//   print(+foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: Expected an identifier, but got '/'.
+//   print(/foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: Expected an identifier, but got '~/'.
+//   print(~/foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: Expected an identifier, but got '*'.
+//   print(*foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: Expected an identifier, but got '%'.
+//   print(%foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: Expected an identifier, but got '|'.
+//   print(|foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: Expected an identifier, but got '^'.
+//   print(^foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: Expected an identifier, but got '&'.
+//   print(&foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: Expected an identifier, but got '<<'.
+//   print(<<foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: Expected an identifier, but got '>>'.
+//   print(>>foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+//   print(foo ~ 2);
+//             ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+  synthetic constructor •() → self::Foo
+    : super core::Object::•()
+    ;
+}
+static method main() → dynamic {
+  self::Foo foo = new self::Foo::•();
+  core::print(foo.<(2));
+  core::print(foo.>(2));
+  core::print(foo.<=(2));
+  core::print(foo.>=(2));
+  core::print(foo.==(2));
+  core::print(foo.-(2));
+  core::print(foo.+(2));
+  core::print(foo./(2));
+  core::print(foo.~/(2));
+  core::print(foo.*(2));
+  core::print(foo.%(2));
+  core::print(foo.|(2));
+  core::print(foo.^(2));
+  core::print(foo.&(2));
+  core::print(foo.<<(2));
+  core::print(foo.>>(2));
+  core::print(let final dynamic #t1 = foo in let final dynamic #t2 = 2 in let final dynamic #t3 = 2 in let final dynamic #t4 = #t1.[]=(#t2, #t3) in #t3);
+  core::print(foo.[](2));
+  core::print(foo.~());
+  core::print(foo.unary-());
+  core::print(<invalid-type>[]);
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: This couldn't be parsed.
+  print(>foo);
+        ^".>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: This couldn't be parsed.
+  print(<=foo);
+        ^".<=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: This couldn't be parsed.
+  print(>=foo);
+        ^".>=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: This couldn't be parsed.
+  print(==foo);
+        ^".==(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: This couldn't be parsed.
+  print(+foo);
+        ^".+(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: This couldn't be parsed.
+  print(/foo);
+        ^"./(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: This couldn't be parsed.
+  print(~/foo);
+        ^".~/(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: This couldn't be parsed.
+  print(*foo);
+        ^".*(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: This couldn't be parsed.
+  print(%foo);
+        ^".%(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: This couldn't be parsed.
+  print(|foo);
+        ^".|(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: This couldn't be parsed.
+  print(^foo);
+        ^".^(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: This couldn't be parsed.
+  print(&foo);
+        ^".&(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: This couldn't be parsed.
+  print(<<foo);
+        ^".<<(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: This couldn't be parsed.
+  print(>>foo);
+        ^".>>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+  print(foo ~ 2);
+            ^");
+}
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart.outline.expect b/pkg/front_end/testcases/operator_method_not_found.dart.outline.expect
new file mode 100644
index 0000000..7835c54
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart.outline.expect
@@ -0,0 +1,10 @@
+library;
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+  synthetic constructor •() → self::Foo
+    ;
+}
+static method main() → dynamic
+  ;
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart.strong.expect b/pkg/front_end/testcases/operator_method_not_found.dart.strong.expect
new file mode 100644
index 0000000..ec89d36
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart.strong.expect
@@ -0,0 +1,344 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Error: Expected '>' after this.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:13: Error: Expected '[' before this.
+//   print(<foo);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Error: 'foo' isn't a type.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: Expected an identifier, but got '>'.
+//   print(>foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: Expected an identifier, but got '<='.
+//   print(<=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: Expected an identifier, but got '>='.
+//   print(>=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: Expected an identifier, but got '=='.
+//   print(==foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: '+' is not a prefix operator.
+// Try removing '+'.
+//   print(+foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: Expected an identifier, but got '/'.
+//   print(/foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: Expected an identifier, but got '~/'.
+//   print(~/foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: Expected an identifier, but got '*'.
+//   print(*foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: Expected an identifier, but got '%'.
+//   print(%foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: Expected an identifier, but got '|'.
+//   print(|foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: Expected an identifier, but got '^'.
+//   print(^foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: Expected an identifier, but got '&'.
+//   print(&foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: Expected an identifier, but got '<<'.
+//   print(<<foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: Expected an identifier, but got '>>'.
+//   print(>>foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+//   print(foo ~ 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:12:13: Error: The method '<' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<'.
+//   print(foo < 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:13:13: Error: The method '>' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '>'.
+//   print(foo > 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:14:13: Error: The method '<=' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<='.
+//   print(foo <= 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:15:13: Error: The method '>=' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '>='.
+//   print(foo >= 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:17:13: Error: The method '-' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '-'.
+//   print(foo - 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:18:13: Error: The method '+' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '+'.
+//   print(foo + 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:19:13: Error: The method '/' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '/'.
+//   print(foo / 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:20:13: Error: The method '~/' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '~/'.
+//   print(foo ~/ 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:21:13: Error: The method '*' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '*'.
+//   print(foo * 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:22:13: Error: The method '%' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '%'.
+//   print(foo % 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:23:13: Error: The method '|' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '|'.
+//   print(foo | 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:24:13: Error: The method '^' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '^'.
+//   print(foo ^ 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:25:13: Error: The method '&' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '&'.
+//   print(foo & 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:26:13: Error: The method '<<' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<<'.
+//   print(foo << 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:27:13: Error: The method '>>' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '>>'.
+//   print(foo >> 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:29:12: Error: The method '[]=' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '[]='.
+//   print(foo[2] = 2);
+//            ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:30:12: Error: The method '[]' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '[]'.
+//   print(foo[2]);
+//            ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:31:9: Error: The method '~' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '~'.
+//   print(~foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:32:9: Error: The method 'unary-' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named 'unary-'.
+//   print(-foo);
+//         ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+  synthetic constructor •() → self::Foo
+    : super core::Object::•()
+    ;
+}
+static method main() → dynamic {
+  self::Foo foo = new self::Foo::•();
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:12:13: Error: The method '<' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<'.
+  print(foo < 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:13:13: Error: The method '>' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '>'.
+  print(foo > 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:14:13: Error: The method '<=' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<='.
+  print(foo <= 2);
+            ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:15:13: Error: The method '>=' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '>='.
+  print(foo >= 2);
+            ^^");
+  core::print(foo.{core::Object::==}(2));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:17:13: Error: The method '-' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '-'.
+  print(foo - 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:18:13: Error: The method '+' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '+'.
+  print(foo + 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:19:13: Error: The method '/' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '/'.
+  print(foo / 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:20:13: Error: The method '~/' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '~/'.
+  print(foo ~/ 2);
+            ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:21:13: Error: The method '*' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '*'.
+  print(foo * 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:22:13: Error: The method '%' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '%'.
+  print(foo % 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:23:13: Error: The method '|' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '|'.
+  print(foo | 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:24:13: Error: The method '^' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '^'.
+  print(foo ^ 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:25:13: Error: The method '&' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '&'.
+  print(foo & 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:26:13: Error: The method '<<' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<<'.
+  print(foo << 2);
+            ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:27:13: Error: The method '>>' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '>>'.
+  print(foo >> 2);
+            ^^");
+  core::print(let final self::Foo #t1 = foo in let final core::int #t2 = 2 in let final core::int #t3 = 2 in let final dynamic #t4 = invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:29:12: Error: The method '[]=' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '[]='.
+  print(foo[2] = 2);
+           ^^^" in #t3);
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:30:12: Error: The method '[]' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '[]'.
+  print(foo[2]);
+           ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:31:9: Error: The method '~' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '~'.
+  print(~foo);
+        ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:32:9: Error: The method 'unary-' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named 'unary-'.
+  print(-foo);
+        ^");
+  core::print(<invalid-type>[]);
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: This couldn't be parsed.
+  print(>foo);
+        ^".>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: This couldn't be parsed.
+  print(<=foo);
+        ^".<=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: This couldn't be parsed.
+  print(>=foo);
+        ^".>=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: This couldn't be parsed.
+  print(==foo);
+        ^".{core::Object::==}(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: This couldn't be parsed.
+  print(+foo);
+        ^".+(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: This couldn't be parsed.
+  print(/foo);
+        ^"./(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: This couldn't be parsed.
+  print(~/foo);
+        ^".~/(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: This couldn't be parsed.
+  print(*foo);
+        ^".*(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: This couldn't be parsed.
+  print(%foo);
+        ^".%(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: This couldn't be parsed.
+  print(|foo);
+        ^".|(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: This couldn't be parsed.
+  print(^foo);
+        ^".^(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: This couldn't be parsed.
+  print(&foo);
+        ^".&(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: This couldn't be parsed.
+  print(<<foo);
+        ^".<<(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: This couldn't be parsed.
+  print(>>foo);
+        ^".>>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+  print(foo ~ 2);
+            ^");
+}
diff --git a/pkg/front_end/testcases/operator_method_not_found.dart.strong.transformed.expect b/pkg/front_end/testcases/operator_method_not_found.dart.strong.transformed.expect
new file mode 100644
index 0000000..ec89d36
--- /dev/null
+++ b/pkg/front_end/testcases/operator_method_not_found.dart.strong.transformed.expect
@@ -0,0 +1,344 @@
+library;
+//
+// Problems in library:
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Error: Expected '>' after this.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:13: Error: Expected '[' before this.
+//   print(<foo);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:36:10: Error: 'foo' isn't a type.
+//   print(<foo);
+//          ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: Expected an identifier, but got '>'.
+//   print(>foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: Expected an identifier, but got '<='.
+//   print(<=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: Expected an identifier, but got '>='.
+//   print(>=foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: Expected an identifier, but got '=='.
+//   print(==foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: '+' is not a prefix operator.
+// Try removing '+'.
+//   print(+foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: Expected an identifier, but got '/'.
+//   print(/foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: Expected an identifier, but got '~/'.
+//   print(~/foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: Expected an identifier, but got '*'.
+//   print(*foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: Expected an identifier, but got '%'.
+//   print(%foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: Expected an identifier, but got '|'.
+//   print(|foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: Expected an identifier, but got '^'.
+//   print(^foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: Expected an identifier, but got '&'.
+//   print(&foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: Expected an identifier, but got '<<'.
+//   print(<<foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: Expected an identifier, but got '>>'.
+//   print(>>foo);
+//         ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+//   print(foo ~ 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:12:13: Error: The method '<' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<'.
+//   print(foo < 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:13:13: Error: The method '>' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '>'.
+//   print(foo > 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:14:13: Error: The method '<=' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<='.
+//   print(foo <= 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:15:13: Error: The method '>=' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '>='.
+//   print(foo >= 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:17:13: Error: The method '-' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '-'.
+//   print(foo - 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:18:13: Error: The method '+' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '+'.
+//   print(foo + 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:19:13: Error: The method '/' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '/'.
+//   print(foo / 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:20:13: Error: The method '~/' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '~/'.
+//   print(foo ~/ 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:21:13: Error: The method '*' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '*'.
+//   print(foo * 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:22:13: Error: The method '%' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '%'.
+//   print(foo % 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:23:13: Error: The method '|' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '|'.
+//   print(foo | 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:24:13: Error: The method '^' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '^'.
+//   print(foo ^ 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:25:13: Error: The method '&' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '&'.
+//   print(foo & 2);
+//             ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:26:13: Error: The method '<<' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '<<'.
+//   print(foo << 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:27:13: Error: The method '>>' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '>>'.
+//   print(foo >> 2);
+//             ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:29:12: Error: The method '[]=' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '[]='.
+//   print(foo[2] = 2);
+//            ^^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:30:12: Error: The method '[]' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '[]'.
+//   print(foo[2]);
+//            ^^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:31:9: Error: The method '~' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named '~'.
+//   print(~foo);
+//         ^
+//
+// pkg/front_end/testcases/operator_method_not_found.dart:32:9: Error: The method 'unary-' isn't defined for the class 'Foo'.
+//  - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+// Try correcting the name to the name of an existing method, or defining a method named 'unary-'.
+//   print(-foo);
+//         ^
+//
+import self as self;
+import "dart:core" as core;
+
+class Foo extends core::Object {
+  synthetic constructor •() → self::Foo
+    : super core::Object::•()
+    ;
+}
+static method main() → dynamic {
+  self::Foo foo = new self::Foo::•();
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:12:13: Error: The method '<' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<'.
+  print(foo < 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:13:13: Error: The method '>' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '>'.
+  print(foo > 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:14:13: Error: The method '<=' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<='.
+  print(foo <= 2);
+            ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:15:13: Error: The method '>=' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '>='.
+  print(foo >= 2);
+            ^^");
+  core::print(foo.{core::Object::==}(2));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:17:13: Error: The method '-' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '-'.
+  print(foo - 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:18:13: Error: The method '+' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '+'.
+  print(foo + 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:19:13: Error: The method '/' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '/'.
+  print(foo / 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:20:13: Error: The method '~/' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '~/'.
+  print(foo ~/ 2);
+            ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:21:13: Error: The method '*' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '*'.
+  print(foo * 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:22:13: Error: The method '%' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '%'.
+  print(foo % 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:23:13: Error: The method '|' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '|'.
+  print(foo | 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:24:13: Error: The method '^' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '^'.
+  print(foo ^ 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:25:13: Error: The method '&' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '&'.
+  print(foo & 2);
+            ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:26:13: Error: The method '<<' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '<<'.
+  print(foo << 2);
+            ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:27:13: Error: The method '>>' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '>>'.
+  print(foo >> 2);
+            ^^");
+  core::print(let final self::Foo #t1 = foo in let final core::int #t2 = 2 in let final core::int #t3 = 2 in let final dynamic #t4 = invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:29:12: Error: The method '[]=' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '[]='.
+  print(foo[2] = 2);
+           ^^^" in #t3);
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:30:12: Error: The method '[]' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '[]'.
+  print(foo[2]);
+           ^^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:31:9: Error: The method '~' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named '~'.
+  print(~foo);
+        ^");
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:32:9: Error: The method 'unary-' isn't defined for the class 'Foo'.
+ - 'Foo' is from 'pkg/front_end/testcases/operator_method_not_found.dart'.
+Try correcting the name to the name of an existing method, or defining a method named 'unary-'.
+  print(-foo);
+        ^");
+  core::print(<invalid-type>[]);
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:37:9: Error: This couldn't be parsed.
+  print(>foo);
+        ^".>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:38:9: Error: This couldn't be parsed.
+  print(<=foo);
+        ^".<=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:39:9: Error: This couldn't be parsed.
+  print(>=foo);
+        ^".>=(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:40:9: Error: This couldn't be parsed.
+  print(==foo);
+        ^".{core::Object::==}(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:41:9: Error: This couldn't be parsed.
+  print(+foo);
+        ^".+(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:42:9: Error: This couldn't be parsed.
+  print(/foo);
+        ^"./(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:43:9: Error: This couldn't be parsed.
+  print(~/foo);
+        ^".~/(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:44:9: Error: This couldn't be parsed.
+  print(*foo);
+        ^".*(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:45:9: Error: This couldn't be parsed.
+  print(%foo);
+        ^".%(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:46:9: Error: This couldn't be parsed.
+  print(|foo);
+        ^".|(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:47:9: Error: This couldn't be parsed.
+  print(^foo);
+        ^".^(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:48:9: Error: This couldn't be parsed.
+  print(&foo);
+        ^".&(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:49:9: Error: This couldn't be parsed.
+  print(<<foo);
+        ^".<<(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:50:9: Error: This couldn't be parsed.
+  print(>>foo);
+        ^".>>(foo));
+  core::print(invalid-expression "pkg/front_end/testcases/operator_method_not_found.dart:54:13: Error: '~' isn't a binary operator.
+  print(foo ~ 2);
+            ^");
+}
diff --git a/pkg/front_end/testcases/strong.status b/pkg/front_end/testcases/strong.status
index 7513191..d6443fb 100644
--- a/pkg/front_end/testcases/strong.status
+++ b/pkg/front_end/testcases/strong.status
@@ -75,6 +75,7 @@
 issue34899: TypeCheckError
 micro: RuntimeError
 mixin_application_override: TypeCheckError
+operator_method_not_found: RuntimeError # Expected
 optional: TypeCheckError
 override_check_accessor_after_inference: TypeCheckError # Issue #31620
 override_check_accessor_basic: TypeCheckError # Issue #31620
diff --git a/pkg/front_end/testcases/text_serialization.status b/pkg/front_end/testcases/text_serialization.status
index 99d0a1f..8e6529f 100644
--- a/pkg/front_end/testcases/text_serialization.status
+++ b/pkg/front_end/testcases/text_serialization.status
@@ -722,6 +722,7 @@
 no_such_method_private_setter: TextSerializationFailure # Was: Pass
 no_such_method_private_setter_lib: TextSerializationFailure # Was: Pass
 null_aware: TextSerializationFailure # Was: Pass
+operator_method_not_found: TextSerializationFailure
 operators: TextSerializationFailure # Was: Pass
 optional: TypeCheckError
 override: TextSerializationFailure # Was: Pass
diff --git a/pkg/kernel/lib/ast.dart b/pkg/kernel/lib/ast.dart
index 44ff8e2..8e41e89 100644
--- a/pkg/kernel/lib/ast.dart
+++ b/pkg/kernel/lib/ast.dart
@@ -6116,7 +6116,7 @@
 /// This function will return "S with M1" and "S with M1, M2", respectively.
 String demangleMixinApplicationName(String name) {
   List<String> nameParts = name.split('&');
-  if (nameParts.length < 2) return name;
+  if (nameParts.length < 2 || name == "&") return name;
   String demangledName = nameParts[1];
   for (int i = 2; i < nameParts.length; i++) {
     demangledName += (i == 2 ? " with " : ", ") + nameParts[i];