blob: a270fe96a57f6cb4b16a595572b18a1ac58c98af [file] [log] [blame]
library;
//
// Problems in library:
//
// pkg/front_end/testcases/patterns/non_constant_pattern_in_switch.dart:44:16: Error: A pattern field in an object pattern must be named.
// Try adding a pattern name or ':' before the pattern.
// case Const(42):
// ^
//
// pkg/front_end/testcases/patterns/non_constant_pattern_in_switch.dart:47:21: Error: A pattern field in an object pattern must be named.
// Try adding a pattern name or ':' before the pattern.
// case Const<num>(42):
// ^
//
import self as self;
import "dart:core" as core;
class Const<T extends core::Object? = dynamic> extends core::Object /*hasConstConstructor*/ {
final field self::Const::T% value;
const constructor •(self::Const::T% value) self::Const<self::Const::T%>
: self::Const::value = value, super core::Object::•()
;
}
static method main() dynamic {
self::test(42, false);
self::test(core::_GrowableList::_literal1<core::int>(42), true);
self::test(core::_GrowableList::_literal1<core::num>(42), true);
self::test(<core::int, core::String>{42: "foo"}, true);
self::test(<core::num, core::Object>{42: "foo"}, true);
self::test(new self::Const::•<core::int>(42), true);
self::test(new self::Const::•<core::num>(42), true);
self::test(#C2, true);
self::test(#C3, true);
self::test(#C5, true);
self::test(#C6, true);
self::test(#C7, true);
self::test(#C8, true);
}
static method test(dynamic value, core::bool expected) void {
core::bool matched;
#L1:
{
final synthesized dynamic #0#0 = value;
synthesized core::bool #0#4;
synthesized core::bool #0#4#isSet = false;
synthesized core::bool #0#8;
synthesized core::bool #0#8#isSet = false;
synthesized dynamic #0#13;
synthesized core::bool #0#13#isSet = false;
synthesized core::bool #0#12;
synthesized core::bool #0#12#isSet = false;
synthesized core::bool #0#15;
synthesized core::bool #0#15#isSet = false;
{
if(#0#0 is core::List<dynamic> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final core::bool* #t1 = #0#4#isSet = true in #0#4 = #0#0{core::List<dynamic>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C9) && (#0#8#isSet ?{core::bool} #0#8{core::bool} : let final core::bool* #t2 = #0#8#isSet = true in #0#8 = #C1 =={core::num::==}{(core::Object) → core::bool} #0#0{core::List<dynamic>}.{core::List::[]}(0){(core::int) → dynamic})) {
{
matched = true;
break #L1;
}
}
}
{
if(#0#0 is core::List<core::num> && (#0#4#isSet ?{core::bool} #0#4{core::bool} : let final core::bool* #t3 = #0#4#isSet = true in #0#4 = #0#0{core::List<core::num>}.{core::List::length}{core::int} =={core::num::==}{(core::Object) → core::bool} #C9) && (#0#8#isSet ?{core::bool} #0#8{core::bool} : let final core::bool* #t4 = #0#8#isSet = true in #0#8 = #C1 =={core::num::==}{(core::Object) → core::bool} #0#0{core::List<core::num>}.{core::List::[]}(0){(core::int) → core::num})) {
{
matched = true;
break #L1;
}
}
}
{
if(#0#0 is core::Map<dynamic, dynamic> && (!((#0#13#isSet ?{dynamic} #0#13{dynamic} : let final core::bool* #t5 = #0#13#isSet = true in #0#13 = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C1){(core::Object?) → dynamic}) == null) || null is dynamic && (#0#12#isSet ?{core::bool} #0#12{core::bool} : let final core::bool* #t6 = #0#12#isSet = true in #0#12 = #0#0{core::Map<dynamic, dynamic>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool})) && (#0#15#isSet ?{core::bool} #0#15{core::bool} : let final core::bool* #t7 = #0#15#isSet = true in #0#15 = #C4 =={core::String::==}{(core::Object) → core::bool} (#0#13#isSet ?{dynamic} #0#13{dynamic} : let final core::bool* #t8 = #0#13#isSet = true in #0#13 = #0#0{core::Map<dynamic, dynamic>}.{core::Map::[]}(#C1){(core::Object?) → dynamic}))) {
{
matched = true;
break #L1;
}
}
}
{
if(#0#0 is core::Map<core::num, core::Object> && (!((#0#13#isSet ?{core::Object?} #0#13{core::Object?} : let final core::bool* #t9 = #0#13#isSet = true in #0#13 = #0#0{core::Map<core::num, core::Object>}.{core::Map::[]}(#C1){(core::Object?) → core::Object?}) == null) || null is core::Object && (#0#12#isSet ?{core::bool} #0#12{core::bool} : let final core::bool* #t10 = #0#12#isSet = true in #0#12 = #0#0{core::Map<core::num, core::Object>}.{core::Map::containsKey}(#C1){(core::Object?) → core::bool})) && (#0#15#isSet ?{core::bool} #0#15{core::bool} : let final core::bool* #t11 = #0#15#isSet = true in #0#15 = #C4 =={core::String::==}{(core::Object) → core::bool} (let core::Object? #t12 = #0#13#isSet ?{core::Object?} #0#13{core::Object?} : let final core::bool* #t13 = #0#13#isSet = true in #0#13 = #0#0{core::Map<core::num, core::Object>}.{core::Map::[]}(#C1){(core::Object?) → core::Object?} in #t12 == null ?{core::Object} #t12 as{Unchecked} core::Object : #t12{core::Object}))) {
{
matched = true;
break #L1;
}
}
}
{
if(#0#0 is self::Const<dynamic>) {
{
matched = true;
break #L1;
}
}
}
{
if(#0#0 is self::Const<core::num>) {
{
matched = true;
break #L1;
}
}
}
{
{
{
matched = false;
break #L1;
}
}
}
}
if(!(matched =={core::Object::==}{(core::Object) core::bool} expected)) {
core::print("FAIL: ${value} ${matched ?{core::String} "matched" : "didn't match"}");
}
}
constants {
#C1 = 42
#C2 = <core::int>[#C1]
#C3 = <core::num>[#C1]
#C4 = "foo"
#C5 = <core::int, core::String>{#C1:#C4}
#C6 = <core::num, core::Object>{#C1:#C4}
#C7 = self::Const<core::int> {value:#C1}
#C8 = self::Const<core::num> {value:#C1}
#C9 = 1
}
Extra constant evaluation status:
Evaluated: IsExpression @ org-dartlang-testcase:///non_constant_pattern_in_switch.dart:38:13 -> BoolConstant(true)
Evaluated: LogicalExpression @ org-dartlang-testcase:///non_constant_pattern_in_switch.dart:41:26 -> BoolConstant(false)
Extra constant evaluation: evaluated: 163, effectively constant: 2
Constructor coverage from constants:
org-dartlang-testcase:///non_constant_pattern_in_switch.dart:
- Const. (from org-dartlang-testcase:///non_constant_pattern_in_switch.dart:8:9)
- Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart)