[core lib] Add unimplemented int.operator >>>
This change adds a placeholder for int.operator >>>.
No implementation is added yet.
This change unblocks implementation of this operator in
the backends (VM, dart2js, DDC).
Issue: https://github.com/dart-lang/sdk/issues/44912
Issue: https://github.com/dart-lang/sdk/issues/30892
Change-Id: I9912ca9f44d594e9c5fa91f5fc65e807fe48cc7a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185480
Commit-Queue: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Reviewed-by: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Nicholas Shahan <nshahan@google.com>
diff --git a/pkg/dev_compiler/lib/src/compiler/js_names.dart b/pkg/dev_compiler/lib/src/compiler/js_names.dart
index 7d3ff1e..81e3899 100644
--- a/pkg/dev_compiler/lib/src/compiler/js_names.dart
+++ b/pkg/dev_compiler/lib/src/compiler/js_names.dart
@@ -399,6 +399,7 @@
'&': 'bitAnd',
'<<': 'leftShift',
'>>': 'rightShift',
+ '>>>': 'tripleShift',
'~': 'bitNot',
// These ones are always renamed, hence the choice of `_` to avoid conflict
// with Dart names. See _emitMemberName.
diff --git a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt
index 960c5e4..98ddc8c 100644
--- a/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt
+++ b/pkg/dev_compiler/tool/dart2js_nnbd_sdk_error_golden.txt
@@ -1,6 +1,7 @@
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|Superinterfaces don't have a valid override for '&': JSNumber.& (num Function(num)), int.& (int Function(int)).
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|Superinterfaces don't have a valid override for '<<': JSNumber.<< (num Function(num)), int.<< (int Function(int)).
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|Superinterfaces don't have a valid override for '>>': JSNumber.>> (num Function(num)), int.>> (int Function(int)).
+ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|Superinterfaces don't have a valid override for '>>>': JSNumber.>>> (num Function(num)), int.>>> (int Function(int)).
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|Superinterfaces don't have a valid override for '\|': JSNumber.\| (num Function(num)), int.\| (int Function(int)).
ERROR|COMPILE_TIME_ERROR|INCONSISTENT_INHERITANCE|lib/_internal/js_runtime/lib/interceptors.dart|Superinterfaces don't have a valid override for '^': JSNumber.^ (num Function(num)), int.^ (int Function(int)).
ERROR|COMPILE_TIME_ERROR|UNDEFINED_OPERATOR|lib/_internal/js_runtime/lib/interceptors.dart|The operator '&' isn't defined for the type 'JSInt'.
diff --git a/pkg/dev_compiler/tool/patch_sdk.dart b/pkg/dev_compiler/tool/patch_sdk.dart
index dd83595..f1cd943 100755
--- a/pkg/dev_compiler/tool/patch_sdk.dart
+++ b/pkg/dev_compiler/tool/patch_sdk.dart
@@ -478,7 +478,7 @@
ParseStringResult _parseString(String source, {bool useNnbd}) {
var features = FeatureSet.fromEnableFlags2(
sdkLanguageVersion: Version.parse('2.10.0'),
- flags: [if (useNnbd) 'non-nullable'],
+ flags: [if (useNnbd) 'non-nullable', 'triple-shift'],
);
return parseString(content: source, featureSet: features);
}
diff --git a/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart b/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart
index 2c56811..e08bdf9 100644
--- a/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart
+++ b/pkg/front_end/lib/src/api_prototype/experimental_flags_generated.dart
@@ -141,6 +141,7 @@
const AllowedExperimentalFlags defaultAllowedExperimentalFlags =
const AllowedExperimentalFlags(sdkDefaultExperiments: {
ExperimentalFlag.nonNullable,
+ ExperimentalFlag.tripleShift,
}, sdkLibraryExperiments: {}, packageExperiments: {
"async": {
ExperimentalFlag.nonNullable,
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.expect b/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.expect
index a425f18..bb1a380 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.expect
@@ -7,25 +7,10 @@
// const int unaryPlus = +2;
// ^
//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int shiftNegative2 = 2 >>> -1;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
// const int divZero = 2 / 0;
// ^
//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift2 = 84 >>> 1;
-// ^^^
-//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift3 = 21 >>> 64;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:5:30: Error: Constant evaluation error:
// const int shiftNegative1 = 2 << -1;
// ^
@@ -36,6 +21,16 @@
// const int shiftNegative1 = 2 << -1;
// ^
//
+// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: Constant evaluation error:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Context: Binary operator '>>>' on '2.0' requires non-negative operand, but was '-1.0'.
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:11: Context: While analyzing:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:7:30: Error: Constant evaluation error:
// const int shiftNegative3 = 2 >> -1;
// ^
@@ -100,10 +95,7 @@
import "dart:core" as core;
static const field core::int* shiftNegative1 = invalid-expression "Binary operator '<<' on '2.0' requires non-negative operand, but was '-1.0'.";
-static const field core::int* shiftNegative2 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int shiftNegative2 = 2 >>> -1;
- ^^^";
+static const field core::int* shiftNegative2 = invalid-expression "Binary operator '>>>' on '2.0' requires non-negative operand, but was '-1.0'.";
static const field core::int* shiftNegative3 = invalid-expression "Binary operator '>>' on '2.0' requires non-negative operand, but was '-1.0'.";
static const field core::int* modZero = invalid-expression "Binary operator '%' on '2.0' requires non-zero divisor, but divisor was '0'.";
static const field core::int* divZero = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
@@ -125,35 +117,30 @@
static const field core::int* binaryAnd = #C3;
static const field core::int* binaryXor = #C3;
static const field core::int* binaryShift1 = #C3;
-static const field core::int* binaryShift2 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift2 = 84 >>> 1;
- ^^^";
-static const field core::int* binaryShift3 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift3 = 21 >>> 64;
- ^^^";
+static const field core::int* binaryShift2 = #C3;
+static const field core::int* binaryShift3 = #C4;
static const field core::int* binaryShift4 = #C3;
-static const field core::int* binaryShift5 = #C4;
-static const field core::bool* binaryLess = #C5;
-static const field core::bool* binaryLessEqual = #C6;
-static const field core::bool* binaryGreaterEqual = #C6;
-static const field core::bool* binaryGreater = #C5;
+static const field core::int* binaryShift5 = #C5;
+static const field core::bool* binaryLess = #C6;
+static const field core::bool* binaryLessEqual = #C7;
+static const field core::bool* binaryGreaterEqual = #C7;
+static const field core::bool* binaryGreater = #C6;
static const field core::int* doubleTruncateDiv = #C3;
static const field core::int* doubleTruncateDivZero = invalid-expression "Binary operator '~/' on '84.2' requires non-zero divisor, but divisor was '0'.";
static const field core::int* doubleTruncateDivNull = invalid-expression "Binary operator '~/' on '84.2' requires operand of type 'num', but was of type 'Null'.";
-static const field core::double* doubleNan = #C7;
+static const field core::double* doubleNan = #C8;
static const field core::int* doubleTruncateDivNaN = invalid-expression "Binary operator '84.2 ~/ NaN' results is Infinity or NaN.";
-static const field core::int* bigNumber = #C8;
+static const field core::int* bigNumber = #C9;
static method main() → dynamic {}
constants {
#C1 = -2.0
#C2 = 4294967293.0
#C3 = 42.0
- #C4 = 4294967295.0
- #C5 = false
- #C6 = true
- #C7 = NaN
- #C8 = 9223372036854776000.0
+ #C4 = 0.0
+ #C5 = 4294967295.0
+ #C6 = false
+ #C7 = true
+ #C8 = NaN
+ #C9 = 9223372036854776000.0
}
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.outline.expect
index 870f990..ce47e53 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.outline.expect
@@ -7,33 +7,15 @@
// const int unaryPlus = +2;
// ^
//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int shiftNegative2 = 2 >>> -1;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
// const int divZero = 2 / 0;
// ^
//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift2 = 84 >>> 1;
-// ^^^
-//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift3 = 21 >>> 64;
-// ^^^
-//
import self as self;
import "dart:core" as core;
static const field core::int* shiftNegative1 = 2.{core::int::<<}(1.{core::int::unary-}(){() →* core::int*}){(core::int*) →* core::int*};
-static const field core::int* shiftNegative2 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int shiftNegative2 = 2 >>> -1;
- ^^^" as{TypeError,ForDynamic} core::int*;
+static const field core::int* shiftNegative2 = 2.{core::int::>>>}(1.{core::int::unary-}(){() →* core::int*}){(core::int*) →* core::int*};
static const field core::int* shiftNegative3 = 2.{core::int::>>}(1.{core::int::unary-}(){() →* core::int*}){(core::int*) →* core::int*};
static const field core::int* modZero = 2.{core::num::%}(0){(core::num*) →* core::int*};
static const field core::int* divZero = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
@@ -55,14 +37,8 @@
static const field core::int* binaryAnd = 63.{core::int::&}(106){(core::int*) →* core::int*};
static const field core::int* binaryXor = 63.{core::int::^}(21){(core::int*) →* core::int*};
static const field core::int* binaryShift1 = 21.{core::int::<<}(1){(core::int*) →* core::int*};
-static const field core::int* binaryShift2 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift2 = 84 >>> 1;
- ^^^" as{TypeError,ForDynamic} core::int*;
-static const field core::int* binaryShift3 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift3 = 21 >>> 64;
- ^^^" as{TypeError,ForDynamic} core::int*;
+static const field core::int* binaryShift2 = 84.{core::int::>>>}(1){(core::int*) →* core::int*};
+static const field core::int* binaryShift3 = 21.{core::int::>>>}(64){(core::int*) →* core::int*};
static const field core::int* binaryShift4 = 84.{core::int::>>}(1){(core::int*) →* core::int*};
static const field core::int* binaryShift5 = 1.{core::int::unary-}(){() →* core::int*}.{core::int::>>}(1){(core::int*) →* core::int*};
static const field core::bool* binaryLess = 42.{core::num::<}(42){(core::num*) →* core::bool*};
@@ -81,6 +57,7 @@
Extra constant evaluation status:
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:5:33 -> DoubleConstant(-1.0)
+Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:6:34 -> DoubleConstant(-1.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:7:33 -> DoubleConstant(-1.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:9:23 -> DoubleConstant(Infinity)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:11:24 -> DoubleConstant(-2.0)
@@ -95,6 +72,8 @@
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:22:26 -> DoubleConstant(42.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:23:26 -> DoubleConstant(42.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:24:29 -> DoubleConstant(42.0)
+Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:27:29 -> DoubleConstant(42.0)
+Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:28:29 -> DoubleConstant(0.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:30:29 -> DoubleConstant(42.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:31:29 -> DoubleConstant(4294967295.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:32:28 -> BoolConstant(false)
@@ -104,4 +83,4 @@
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:37:36 -> DoubleConstant(42.0)
Evaluated: InstanceInvocation @ org-dartlang-testcase:///number_folds.dart:40:27 -> DoubleConstant(NaN)
Evaluated: StaticGet @ org-dartlang-testcase:///number_folds.dart:41:42 -> DoubleConstant(NaN)
-Extra constant evaluation: evaluated: 38, effectively constant: 24
+Extra constant evaluation: evaluated: 39, effectively constant: 27
diff --git a/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.transformed.expect
index a425f18..bb1a380 100644
--- a/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart.weak.transformed.expect
@@ -7,25 +7,10 @@
// const int unaryPlus = +2;
// ^
//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int shiftNegative2 = 2 >>> -1;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
// const int divZero = 2 / 0;
// ^
//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift2 = 84 >>> 1;
-// ^^^
-//
-// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift3 = 21 >>> 64;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:5:30: Error: Constant evaluation error:
// const int shiftNegative1 = 2 << -1;
// ^
@@ -36,6 +21,16 @@
// const int shiftNegative1 = 2 << -1;
// ^
//
+// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: Constant evaluation error:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Context: Binary operator '>>>' on '2.0' requires non-negative operand, but was '-1.0'.
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:11: Context: While analyzing:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+//
// pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:7:30: Error: Constant evaluation error:
// const int shiftNegative3 = 2 >> -1;
// ^
@@ -100,10 +95,7 @@
import "dart:core" as core;
static const field core::int* shiftNegative1 = invalid-expression "Binary operator '<<' on '2.0' requires non-negative operand, but was '-1.0'.";
-static const field core::int* shiftNegative2 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int shiftNegative2 = 2 >>> -1;
- ^^^";
+static const field core::int* shiftNegative2 = invalid-expression "Binary operator '>>>' on '2.0' requires non-negative operand, but was '-1.0'.";
static const field core::int* shiftNegative3 = invalid-expression "Binary operator '>>' on '2.0' requires non-negative operand, but was '-1.0'.";
static const field core::int* modZero = invalid-expression "Binary operator '%' on '2.0' requires non-zero divisor, but divisor was '0'.";
static const field core::int* divZero = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
@@ -125,35 +117,30 @@
static const field core::int* binaryAnd = #C3;
static const field core::int* binaryXor = #C3;
static const field core::int* binaryShift1 = #C3;
-static const field core::int* binaryShift2 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift2 = 84 >>> 1;
- ^^^";
-static const field core::int* binaryShift3 = invalid-expression "pkg/front_end/testcases/general/constants/js_semantics/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift3 = 21 >>> 64;
- ^^^";
+static const field core::int* binaryShift2 = #C3;
+static const field core::int* binaryShift3 = #C4;
static const field core::int* binaryShift4 = #C3;
-static const field core::int* binaryShift5 = #C4;
-static const field core::bool* binaryLess = #C5;
-static const field core::bool* binaryLessEqual = #C6;
-static const field core::bool* binaryGreaterEqual = #C6;
-static const field core::bool* binaryGreater = #C5;
+static const field core::int* binaryShift5 = #C5;
+static const field core::bool* binaryLess = #C6;
+static const field core::bool* binaryLessEqual = #C7;
+static const field core::bool* binaryGreaterEqual = #C7;
+static const field core::bool* binaryGreater = #C6;
static const field core::int* doubleTruncateDiv = #C3;
static const field core::int* doubleTruncateDivZero = invalid-expression "Binary operator '~/' on '84.2' requires non-zero divisor, but divisor was '0'.";
static const field core::int* doubleTruncateDivNull = invalid-expression "Binary operator '~/' on '84.2' requires operand of type 'num', but was of type 'Null'.";
-static const field core::double* doubleNan = #C7;
+static const field core::double* doubleNan = #C8;
static const field core::int* doubleTruncateDivNaN = invalid-expression "Binary operator '84.2 ~/ NaN' results is Infinity or NaN.";
-static const field core::int* bigNumber = #C8;
+static const field core::int* bigNumber = #C9;
static method main() → dynamic {}
constants {
#C1 = -2.0
#C2 = 4294967293.0
#C3 = 42.0
- #C4 = 4294967295.0
- #C5 = false
- #C6 = true
- #C7 = NaN
- #C8 = 9223372036854776000.0
+ #C4 = 0.0
+ #C5 = 4294967295.0
+ #C6 = false
+ #C7 = true
+ #C8 = NaN
+ #C9 = 9223372036854776000.0
}
diff --git a/pkg/front_end/testcases/general/constants/number_folds.dart.weak.expect b/pkg/front_end/testcases/general/constants/number_folds.dart.weak.expect
index f20a0df..dc5a80f 100644
--- a/pkg/front_end/testcases/general/constants/number_folds.dart.weak.expect
+++ b/pkg/front_end/testcases/general/constants/number_folds.dart.weak.expect
@@ -7,25 +7,10 @@
// const int unaryPlus = +2;
// ^
//
-// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int shiftNegative2 = 2 >>> -1;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
// const int divZero = 2 / 0;
// ^
//
-// pkg/front_end/testcases/general/constants/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift2 = 84 >>> 1;
-// ^^^
-//
-// pkg/front_end/testcases/general/constants/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift3 = 21 >>> 64;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/number_folds.dart:5:30: Error: Constant evaluation error:
// const int shiftNegative1 = 2 << -1;
// ^
@@ -36,6 +21,16 @@
// const int shiftNegative1 = 2 << -1;
// ^
//
+// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: Constant evaluation error:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Context: Binary operator '>>>' on '2' requires non-negative operand, but was '-1'.
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/number_folds.dart:6:11: Context: While analyzing:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+//
// pkg/front_end/testcases/general/constants/number_folds.dart:7:30: Error: Constant evaluation error:
// const int shiftNegative3 = 2 >> -1;
// ^
@@ -100,10 +95,7 @@
import "dart:core" as core;
static const field core::int* shiftNegative1 = invalid-expression "Binary operator '<<' on '2' requires non-negative operand, but was '-1'.";
-static const field core::int* shiftNegative2 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int shiftNegative2 = 2 >>> -1;
- ^^^";
+static const field core::int* shiftNegative2 = invalid-expression "Binary operator '>>>' on '2' requires non-negative operand, but was '-1'.";
static const field core::int* shiftNegative3 = invalid-expression "Binary operator '>>' on '2' requires non-negative operand, but was '-1'.";
static const field core::int* modZero = invalid-expression "Binary operator '%' on '2' requires non-zero divisor, but divisor was '0'.";
static const field core::int* divZero = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
@@ -125,23 +117,17 @@
static const field core::int* binaryAnd = #C3;
static const field core::int* binaryXor = #C3;
static const field core::int* binaryShift1 = #C3;
-static const field core::int* binaryShift2 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift2 = 84 >>> 1;
- ^^^";
-static const field core::int* binaryShift3 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift3 = 21 >>> 64;
- ^^^";
+static const field core::int* binaryShift2 = #C3;
+static const field core::int* binaryShift3 = #C5;
static const field core::int* binaryShift4 = #C3;
-static const field core::bool* binaryLess = #C5;
-static const field core::bool* binaryLessEqual = #C6;
-static const field core::bool* binaryGreaterEqual = #C6;
-static const field core::bool* binaryGreater = #C5;
+static const field core::bool* binaryLess = #C6;
+static const field core::bool* binaryLessEqual = #C7;
+static const field core::bool* binaryGreaterEqual = #C7;
+static const field core::bool* binaryGreater = #C6;
static const field core::int* doubleTruncateDiv = #C3;
static const field core::int* doubleTruncateDivZero = invalid-expression "Binary operator '~/' on '84.2' requires non-zero divisor, but divisor was '0'.";
static const field core::int* doubleTruncateDivNull = invalid-expression "Binary operator '~/' on '84.2' requires operand of type 'num', but was of type 'Null'.";
-static const field core::double* doubleNan = #C7;
+static const field core::double* doubleNan = #C8;
static const field core::int* doubleTruncateDivNaN = invalid-expression "Binary operator '84.2 ~/ NaN' results is Infinity or NaN.";
static method main() → dynamic {}
@@ -150,7 +136,8 @@
#C2 = -3
#C3 = 42
#C4 = 42.0
- #C5 = false
- #C6 = true
- #C7 = NaN
+ #C5 = 0
+ #C6 = false
+ #C7 = true
+ #C8 = NaN
}
diff --git a/pkg/front_end/testcases/general/constants/number_folds.dart.weak.outline.expect b/pkg/front_end/testcases/general/constants/number_folds.dart.weak.outline.expect
index 0c36235..f1e66af 100644
--- a/pkg/front_end/testcases/general/constants/number_folds.dart.weak.outline.expect
+++ b/pkg/front_end/testcases/general/constants/number_folds.dart.weak.outline.expect
@@ -7,33 +7,15 @@
// const int unaryPlus = +2;
// ^
//
-// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int shiftNegative2 = 2 >>> -1;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
// const int divZero = 2 / 0;
// ^
//
-// pkg/front_end/testcases/general/constants/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift2 = 84 >>> 1;
-// ^^^
-//
-// pkg/front_end/testcases/general/constants/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift3 = 21 >>> 64;
-// ^^^
-//
import self as self;
import "dart:core" as core;
static const field core::int* shiftNegative1 = 2.{core::int::<<}(1.{core::int::unary-}());
-static const field core::int* shiftNegative2 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int shiftNegative2 = 2 >>> -1;
- ^^^" as{TypeError,ForDynamic} core::int*;
+static const field core::int* shiftNegative2 = 2.{core::int::>>>}(1.{core::int::unary-}());
static const field core::int* shiftNegative3 = 2.{core::int::>>}(1.{core::int::unary-}());
static const field core::int* modZero = 2.{core::num::%}(0);
static const field core::int* divZero = let final<BottomType> #t1 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
@@ -55,14 +37,8 @@
static const field core::int* binaryAnd = 63.{core::int::&}(106);
static const field core::int* binaryXor = 63.{core::int::^}(21);
static const field core::int* binaryShift1 = 21.{core::int::<<}(1);
-static const field core::int* binaryShift2 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift2 = 84 >>> 1;
- ^^^" as{TypeError,ForDynamic} core::int*;
-static const field core::int* binaryShift3 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift3 = 21 >>> 64;
- ^^^" as{TypeError,ForDynamic} core::int*;
+static const field core::int* binaryShift2 = 84.{core::int::>>>}(1);
+static const field core::int* binaryShift3 = 21.{core::int::>>>}(64);
static const field core::int* binaryShift4 = 84.{core::int::>>}(1);
static const field core::bool* binaryLess = 42.{core::num::<}(42);
static const field core::bool* binaryLessEqual = 42.{core::num::<=}(42);
@@ -79,6 +55,7 @@
Extra constant evaluation status:
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:5:33 -> IntConstant(-1)
+Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:6:34 -> IntConstant(-1)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:7:33 -> IntConstant(-1)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:9:23 -> DoubleConstant(Infinity)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:11:24 -> IntConstant(-2)
@@ -93,6 +70,8 @@
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:22:26 -> IntConstant(42)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:23:26 -> IntConstant(42)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:24:29 -> IntConstant(42)
+Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:27:29 -> IntConstant(42)
+Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:28:29 -> IntConstant(0)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:30:29 -> IntConstant(42)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:31:28 -> BoolConstant(false)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:32:33 -> BoolConstant(true)
@@ -101,4 +80,4 @@
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:36:36 -> IntConstant(42)
Evaluated: MethodInvocation @ org-dartlang-testcase:///number_folds.dart:39:27 -> DoubleConstant(NaN)
Evaluated: StaticGet @ org-dartlang-testcase:///number_folds.dart:40:42 -> DoubleConstant(NaN)
-Extra constant evaluation: evaluated: 37, effectively constant: 23
+Extra constant evaluation: evaluated: 38, effectively constant: 26
diff --git a/pkg/front_end/testcases/general/constants/number_folds.dart.weak.transformed.expect b/pkg/front_end/testcases/general/constants/number_folds.dart.weak.transformed.expect
index f20a0df..dc5a80f 100644
--- a/pkg/front_end/testcases/general/constants/number_folds.dart.weak.transformed.expect
+++ b/pkg/front_end/testcases/general/constants/number_folds.dart.weak.transformed.expect
@@ -7,25 +7,10 @@
// const int unaryPlus = +2;
// ^
//
-// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int shiftNegative2 = 2 >>> -1;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
// const int divZero = 2 / 0;
// ^
//
-// pkg/front_end/testcases/general/constants/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift2 = 84 >>> 1;
-// ^^^
-//
-// pkg/front_end/testcases/general/constants/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-// Try correcting the operator to an existing operator, or defining a '>>>' operator.
-// const int binaryShift3 = 21 >>> 64;
-// ^^^
-//
// pkg/front_end/testcases/general/constants/number_folds.dart:5:30: Error: Constant evaluation error:
// const int shiftNegative1 = 2 << -1;
// ^
@@ -36,6 +21,16 @@
// const int shiftNegative1 = 2 << -1;
// ^
//
+// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: Constant evaluation error:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Context: Binary operator '>>>' on '2' requires non-negative operand, but was '-1'.
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+// pkg/front_end/testcases/general/constants/number_folds.dart:6:11: Context: While analyzing:
+// const int shiftNegative2 = 2 >>> -1;
+// ^
+//
// pkg/front_end/testcases/general/constants/number_folds.dart:7:30: Error: Constant evaluation error:
// const int shiftNegative3 = 2 >> -1;
// ^
@@ -100,10 +95,7 @@
import "dart:core" as core;
static const field core::int* shiftNegative1 = invalid-expression "Binary operator '<<' on '2' requires non-negative operand, but was '-1'.";
-static const field core::int* shiftNegative2 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:6:30: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int shiftNegative2 = 2 >>> -1;
- ^^^";
+static const field core::int* shiftNegative2 = invalid-expression "Binary operator '>>>' on '2' requires non-negative operand, but was '-1'.";
static const field core::int* shiftNegative3 = invalid-expression "Binary operator '>>' on '2' requires non-negative operand, but was '-1'.";
static const field core::int* modZero = invalid-expression "Binary operator '%' on '2' requires non-zero divisor, but divisor was '0'.";
static const field core::int* divZero = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:9:23: Error: A value of type 'double' can't be assigned to a variable of type 'int'.
@@ -125,23 +117,17 @@
static const field core::int* binaryAnd = #C3;
static const field core::int* binaryXor = #C3;
static const field core::int* binaryShift1 = #C3;
-static const field core::int* binaryShift2 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:27:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift2 = 84 >>> 1;
- ^^^";
-static const field core::int* binaryShift3 = invalid-expression "pkg/front_end/testcases/general/constants/number_folds.dart:28:29: Error: The operator '>>>' isn't defined for the class 'int'.
-Try correcting the operator to an existing operator, or defining a '>>>' operator.
-const int binaryShift3 = 21 >>> 64;
- ^^^";
+static const field core::int* binaryShift2 = #C3;
+static const field core::int* binaryShift3 = #C5;
static const field core::int* binaryShift4 = #C3;
-static const field core::bool* binaryLess = #C5;
-static const field core::bool* binaryLessEqual = #C6;
-static const field core::bool* binaryGreaterEqual = #C6;
-static const field core::bool* binaryGreater = #C5;
+static const field core::bool* binaryLess = #C6;
+static const field core::bool* binaryLessEqual = #C7;
+static const field core::bool* binaryGreaterEqual = #C7;
+static const field core::bool* binaryGreater = #C6;
static const field core::int* doubleTruncateDiv = #C3;
static const field core::int* doubleTruncateDivZero = invalid-expression "Binary operator '~/' on '84.2' requires non-zero divisor, but divisor was '0'.";
static const field core::int* doubleTruncateDivNull = invalid-expression "Binary operator '~/' on '84.2' requires operand of type 'num', but was of type 'Null'.";
-static const field core::double* doubleNan = #C7;
+static const field core::double* doubleNan = #C8;
static const field core::int* doubleTruncateDivNaN = invalid-expression "Binary operator '84.2 ~/ NaN' results is Infinity or NaN.";
static method main() → dynamic {}
@@ -150,7 +136,8 @@
#C2 = -3
#C3 = 42
#C4 = 42.0
- #C5 = false
- #C6 = true
- #C7 = NaN
+ #C5 = 0
+ #C6 = false
+ #C7 = true
+ #C8 = NaN
}
diff --git a/sdk/lib/_internal/allowed_experiments.json b/sdk/lib/_internal/allowed_experiments.json
index 4644443..66da861 100644
--- a/sdk/lib/_internal/allowed_experiments.json
+++ b/sdk/lib/_internal/allowed_experiments.json
@@ -1,13 +1,17 @@
{
"version": 1,
"experimentSets": {
+ "sdkExperiments": [
+ "non-nullable",
+ "triple-shift"
+ ],
"nullSafety": [
"non-nullable"
]
},
"sdk": {
"default": {
- "experimentSet": "nullSafety"
+ "experimentSet": "sdkExperiments"
},
"_example_libraries": {
"ui": {
diff --git a/sdk/lib/_internal/js_dev_runtime/private/js_number.dart b/sdk/lib/_internal/js_dev_runtime/private/js_number.dart
index 60b9246..c70de91 100644
--- a/sdk/lib/_internal/js_dev_runtime/private/js_number.dart
+++ b/sdk/lib/_internal/js_dev_runtime/private/js_number.dart
@@ -335,6 +335,9 @@
return _shrOtherPositive(other);
}
+ int operator >>>(@nullCheck num other) =>
+ throw UnimplementedError('int.>>> is not implemented yet');
+
@notNull
int _shrOtherPositive(@notNull num other) {
return JS<num>('!', '#', this) > 0
diff --git a/sdk/lib/_internal/js_runtime/lib/js_number.dart b/sdk/lib/_internal/js_runtime/lib/js_number.dart
index eac0bc3..1d3ad24 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_number.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_number.dart
@@ -404,6 +404,9 @@
return _shrOtherPositive(other);
}
+ num operator >>>(num other) =>
+ throw UnimplementedError('int.>>> is not implemented yet');
+
num _shrOtherPositive(num other) {
return JS('num', '#', this) > 0
? _shrBothPositive(other)
diff --git a/sdk/lib/_internal/vm/lib/integers.dart b/sdk/lib/_internal/vm/lib/integers.dart
index 3ce3af5..f53e439 100644
--- a/sdk/lib/_internal/vm/lib/integers.dart
+++ b/sdk/lib/_internal/vm/lib/integers.dart
@@ -105,6 +105,9 @@
@pragma("vm:non-nullable-result-type")
@pragma("vm:never-inline")
int operator >>(int other) => other._shrFromInteger(this);
+ @pragma("vm:never-inline")
+ int operator >>>(int other) =>
+ throw UnimplementedError('int.>>> is not implemented yet');
@pragma("vm:recognized", "asm-intrinsic")
@pragma("vm:non-nullable-result-type")
@pragma("vm:never-inline")
diff --git a/sdk/lib/core/int.dart b/sdk/lib/core/int.dart
index 1578770..dd35a3f 100644
--- a/sdk/lib/core/int.dart
+++ b/sdk/lib/core/int.dart
@@ -105,6 +105,17 @@
/// It is an error if [shiftAmount] is negative.
int operator >>(int shiftAmount);
+ /// Bitwise unsigned right shift by [shiftAmount] bits.
+ ///
+ /// NOT IMPLEMENTED YET.
+ ///
+ /// The least significant [shiftAmount] bits are dropped,
+ /// the remaining bits (if any) are shifted down,
+ /// and zero-bits are shifted in as the new most signficant bits.
+ ///
+ /// The [shiftAmount] must be non-negative.
+ int operator >>>(int shiftAmount);
+
/// Returns this integer to the power of [exponent] modulo [modulus].
///
/// The [exponent] must be non-negative and [modulus] must be