Files
sdk/pkg/front_end/testcases/inference/infer_binary_int_double.dart
T
Paul Berry a1ecb46a4c Fix top level type inference for binary operators.
Multiple changes were required:

- The analyzer's mock SDK had an incorrect return type for
  `num.operator/`.

- We weren't considering the RHS of the binary operators `+`, `-`,
  `*`, and `%` to be an inference dependency (we need to, since the
  special overload rules for int depend on the type of the RHS).

- We weren't executing the overload logic when doing top level type
  inference.

- The logic for deciding what operators are overloaded was incorrect.

R=scheglov@google.com

Review-Url: https://codereview.chromium.org/2940703002 .
2017-06-13 13:07:00 -07:00

35 lines
1.2 KiB
Dart

// Copyright (c) 2017, 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.
/*@testedFeatures=inference*/
library test;
var /*@topType=bool*/ a_equal = 1 /*@target=num::==*/ == 2.0;
var /*@topType=bool*/ a_notEqual = 1 /*@target=num::==*/ != 2.0;
var /*@topType=double*/ a_add = 1 /*@target=num::+*/ + 2.0;
var /*@topType=double*/ a_subtract = 1 /*@target=num::-*/ - 2.0;
var /*@topType=double*/ a_multiply = 1 /*@target=num::**/ * 2.0;
var /*@topType=double*/ a_divide = 1 /*@target=num::/ */ / 2.0;
var /*@topType=int*/ a_floorDivide = 1 /*@target=num::~/ */ ~/ 2.0;
var /*@topType=bool*/ a_greater = 1 /*@target=num::>*/ > 2.0;
var /*@topType=bool*/ a_less = 1 /*@target=num::<*/ < 2.0;
var /*@topType=bool*/ a_greaterEqual = 1 /*@target=num::>=*/ >= 2.0;
var /*@topType=bool*/ a_lessEqual = 1 /*@target=num::<=*/ <= 2.0;
var /*@topType=double*/ a_modulo = 1 /*@target=num::%*/ % 2.0;
main() {
a_equal;
a_notEqual;
a_add;
a_subtract;
a_multiply;
a_divide;
a_floorDivide;
a_greater;
a_less;
a_greaterEqual;
a_lessEqual;
a_modulo;
}