blob: abd661dadd272f95c535ad22e3c234700cf0fd71 [file] [log] [blame]
library /*isNonNullableByDefault*/;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/shared_errors.dart:13:13: Error: The argument type 'int' can't be assigned to the parameter type 'Class'.
// - 'Class' is from 'pkg/front_end/testcases/patterns/shared_errors.dart'.
// case >= 0: // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:20:10: Error: A value of type 'Class' can't be assigned to a variable of type 'bool'.
// - 'Class' is from 'pkg/front_end/testcases/patterns/shared_errors.dart'.
// case > 0: // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:26:12: Error: The matched value of type 'List<String>' isn't assignable to the required type 'List<int>'.
// - 'List' is from 'dart:core'.
// Try changing the required type of the pattern, or the matched value type.
// var <int>[a] = list; // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:31:7: Error: The variable 'a' is already assigned in this pattern.
// Try renaming the variable.
// [a, a] = list; // Error
// ^
// pkg/front_end/testcases/patterns/shared_errors.dart:31:4: Context: The first assigned variable pattern.
// [a, a] = list; // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:36:28: Error: The field 'field' is already matched in this pattern.
// Try removing the duplicate field.
// case (field: 1, field: 2): // Error
// ^
// pkg/front_end/testcases/patterns/shared_errors.dart:36:18: Context: The first field.
// case (field: 1, field: 2): // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:37:33: Error: The field 'field' is already matched in this pattern.
// Try removing the duplicate field.
// case Class(field: 1, field: 2): // Error
// ^
// pkg/front_end/testcases/patterns/shared_errors.dart:37:23: Context: The first field.
// case Class(field: 1, field: 2): // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:45:11: Error: At most one rest element is allowed in a list or map pattern.
// Try removing the duplicate rest element.
// case {..., ...}: // Error
// ^
// pkg/front_end/testcases/patterns/shared_errors.dart:45:16: Context: The first rest element.
// case {..., ...}: // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:44:16: Error: At most one rest element is allowed in a list or map pattern.
// Try removing the duplicate rest element.
// case [..., ...]: // Error
// ^
// pkg/front_end/testcases/patterns/shared_errors.dart:44:11: Context: The first rest element.
// case [..., ...]: // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:50:23: Warning: The null-assert pattern will have no effect because the matched type isn't nullable.
// Try replacing the null-assert pattern with its nested pattern.
// if (list case [var a!, var b?]) { // Warnings
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:50:31: Warning: The null-check pattern will have no effect because the matched type isn't nullable.
// Try replacing the null-check pattern with its nested pattern.
// if (list case [var a!, var b?]) { // Warnings
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:56:21: Error: Conditions must have a static type of 'bool'.
// Try changing the condition.
// if (i case 0 when i) { // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:62:9: Error: Refutable patterns can't be used in an irrefutable context.
// Try using an if-case, a 'switch' statement, or a 'switch' expression instead.
// var (a?) = x; // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:66:15: Error: The '...' pattern can appear only at the end in map patterns.
// if (o case {..., 5: 3}) { // Error
// ^
//
// pkg/front_end/testcases/patterns/shared_errors.dart:72:21: Error: A rest element in a map pattern can't have a subpattern.
// Try removing the subpattern.
// if (o case {5: 3, ...var a}) { // Error
// ^
//
import self as self;
import "dart:core" as core;
import "dart:_internal" as _in;
class Class extends core::Object {
synthetic constructor •() self::Class
: super core::Object::•()
;
get field() core::int
return 42;
operator >=(self::Class cls) core::bool
return true;
operator >(core::int i) self::Class
return new self::Class::•();
}
static method argumentTypeNotAssignable(self::Class cls) dynamic {
#L1:
{
core::int #t1 = -1;
final self::Class #0#0 = cls;
if(#0#0.{self::Class::>=}(invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:13:13: Error: The argument type 'int' can't be assigned to the parameter type 'Class'.
- 'Class' is from 'pkg/front_end/testcases/patterns/shared_errors.dart'.
case >= 0: // Error
^" in #C1 as{TypeError,ForNonNullableByDefault} self::Class){(self::Class) → core::bool}) {
#t1 = 0;
}
switch(#t1) {
#L2:
case #C1:
{
{
core::print(0);
}
}
}
}
}
static method relationalPatternOperatorReturnTypeNotAssignableToBool(self::Class cls) → dynamic {
#L3:
{
core::int #t2 = -1;
if(invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:20:10: Error: A value of type 'Class' can't be assigned to a variable of type 'bool'.
- 'Class' is from 'pkg/front_end/testcases/patterns/shared_errors.dart'.
case > 0: // Error
^") {
#t2 = 0;
}
switch(#t2) {
#L4:
case #C1:
{
{
core::print(0);
}
}
}
}
}
static method patternTypeMismatchInIrrefutableContext(core::List<core::String> list) → dynamic {
core::int a;
if(!invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:26:12: Error: The matched value of type 'List<String>' isn't assignable to the required type 'List<int>'.
- 'List' is from 'dart:core'.
Try changing the required type of the pattern, or the matched value type.
var <int>[a] = list; // Error
^")
throw new _in::ReachabilityError::•();
}
static method duplicateAssignmentPatternVariable(core::List<core::String> list) → dynamic {
core::String a = "";
block {
final dynamic #0#0 = list;
if(!(#0#0 is{ForNonNullableByDefault} core::List<dynamic> && #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C2 && (let final dynamic #t3 = a = #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic} as{ForNonNullableByDefault} core::String in true) && (let final dynamic #t4 = #0#0{core::List<dynamic>}.{core::List::[]}(1){(core::int) → dynamic} in invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:31:7: Error: The variable 'a' is already assigned in this pattern.
Try renaming the variable.
[a, a] = list; // Error
^")))
throw new _in::ReachabilityError::•();
} =>#0#0;
}
static method duplicateRecordPatternField(dynamic o) → dynamic {
#L5:
{
core::int #t5 = -1;
if(invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:36:28: Error: The field 'field' is already matched in this pattern.
Try removing the duplicate field.
case (field: 1, field: 2): // Error
^" || invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:37:33: Error: The field 'field' is already matched in this pattern.
Try removing the duplicate field.
case Class(field: 1, field: 2): // Error
^") {
#t5 = 0;
}
switch(#t5) {
#L6:
case #C1:
{
{
core::print(0);
}
}
}
}
}
static method duplicateRestPattern(dynamic o) → dynamic {
#L7:
{
core::int #t6 = -1;
final dynamic #0#0 = o;
if(invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:44:16: Error: At most one rest element is allowed in a list or map pattern.
Try removing the duplicate rest element.
case [..., ...]: // Error
^" || #0#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::length}{core::int}.{core::num::>=}(#C1){(core::num) → core::bool}) {
#t6 = 0;
}
switch(#t6) {
#L8:
case #C1:
{}
}
}
}
static method matchedTypeIsStrictlyNonNullable(core::List<core::int> list) → dynamic {
{
core::int a;
core::int b;
final core::List<core::int> #0#0 = list;
late final dynamic #0#4 = #0#0.{core::List::[]}(0){(core::int) → dynamic};
late final dynamic #0#6 = #0#0.{core::List::[]}(1){(core::int) → dynamic};
if(#0#0.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C2 && (let final dynamic #t7 = #0#4! in let final dynamic #t8 = a = #0#4! as{ForNonNullableByDefault} core::int in true) && (!(#0#6 == null) ?{core::bool} let final dynamic #t9 = b = #0#6{core::int} in true : false)) {
core::print(0);
}
}
}
static method nonBooleanCondition(core::int i) → dynamic {
{
final core::int #0#0 = i;
if(#C1 =={core::num::==}{(core::Object) → core::bool} #0#0 && i) {
core::print(0);
}
}
}
static method refutablePatternInIrrefutableContext(core::int? x) → dynamic {
core::int a;
if(!invalid-expression "pkg/front_end/testcases/patterns/shared_errors.dart:62:9: Error: Refutable patterns can't be used in an irrefutable context.
Try using an if-case, a 'switch' statement, or a 'switch' expression instead.
var (a?) = x; // Error
^")
throw new _in::ReachabilityError::•();
}
static method restPatternNotLastInMap(dynamic o) → dynamic {
{
final dynamic #0#0 = o;
if(#0#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::length}{core::int}.{core::num::>=}(#C3){(core::num) → core::bool} && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && #C5 =={core::num::==}{(core::Object) → core::bool} #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic}) {
core::print(0);
}
}
}
static method restPatternWithSubPatternInMap(dynamic o) → dynamic {
{
final dynamic #0#0 = o;
if(#0#0 is{ForNonNullableByDefault} core::Map<dynamic, dynamic> && #0#0{core::Map<dynamic, dynamic>}.{core::Map::length}{core::int}.{core::num::>=}(#C3){(core::num) → core::bool} && #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C4){(core::Object?) → core::bool} && #C5 =={core::num::==}{(core::Object) → core::bool} #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C4){(core::Object?) → dynamic}) {
core::print(0);
}
}
}
constants {
#C1 = 0
#C2 = 2
#C3 = 1
#C4 = 5
#C5 = 3
}