Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(610)

Unified Diff: pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart

Issue 2940703002: Fix top level type inference for binary operators. (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
diff --git a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
index 1c1b7a20dacb1d5a76a885ed0afa45fc46347903..4c3d53ae8e53c8d184bdf70bcac52627e4e986cd 100644
--- a/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
+++ b/pkg/front_end/lib/src/fasta/type_inference/type_schema_environment.dart
@@ -399,6 +399,19 @@ class TypeSchemaEnvironment extends TypeEnvironment {
return context == null;
}
+ /// True if [member] is a binary operator that returns an `int` if both
+ /// operands are `int`, and otherwise returns `double`.
+ ///
+ /// This is a case of type-based overloading, which in Dart is only supported
+ /// by giving special treatment to certain arithmetic operators.
+ bool isOverloadedArithmeticOperator(Procedure member) {
+ // TODO(paulberry): this matches what is defined in the spec. It would be
+ // nice if we could change kernel to match the spec and not have to
+ // override.
+ if (member.name.name == 'remainder') return false;
+ return super.isOverloadedArithmeticOperator(member);
+ }
+
@override
bool isTop(DartType t) {
if (t is UnknownType) {

Powered by Google App Engine
This is Rietveld 408576698