2a1224f3b5
This enables the check for primitive equals in switch cases in legacy libraries. Change-Id: Iddc464f39525d5167a5c6e8c40c95acc3c245d76 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231701 Reviewed-by: Joshua Litt <joshualitt@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
26 lines
773 B
Dart
26 lines
773 B
Dart
// Copyright (c) 2014, 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.
|
|
|
|
// @dart = 2.9
|
|
|
|
import 'package:expect/expect.dart';
|
|
|
|
int main() {
|
|
var a = [1, 2, 3][2];
|
|
switch (a) {
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.SWITCH_EXPRESSION_NOT_ASSIGNABLE
|
|
case 0.0:
|
|
// ^
|
|
// [cfe] Case expression '0.0' does not have a primitive operator '=='.
|
|
// [cfe] Type 'int' of the switch expression isn't assignable to the type 'double' of this case expression.
|
|
print("illegal");
|
|
break;
|
|
case 1:
|
|
// ^
|
|
// [analyzer] COMPILE_TIME_ERROR.INCONSISTENT_CASE_EXPRESSION_TYPES
|
|
print("OK");
|
|
}
|
|
}
|