| library; | |
| // | |
| // Problems in library: | |
| // | |
| // pkg/front_end/testcases/nnbd/switch_nullable_enum.dart:9:5: Error: A non-null value must be returned since the return type 'int' doesn't allow null. | |
| // int method1(Enum? e) { | |
| // ^ | |
| // | |
| import self as self; | |
| import "dart:core" as core; | |
| class Enum extends core::_Enum /*isEnum*/ { | |
| enum-element static const field self::Enum e1 = #C3; | |
| enum-element static const field self::Enum e2 = #C6; | |
| static const field core::List<self::Enum> values = #C7; | |
| const synthetic constructor •(core::int #index, core::String #name) → self::Enum | |
| : super core::_Enum::•(#index, #name) | |
| ; | |
| method core::_enumToString() → core::String | |
| return "Enum.${this.{core::_Enum::_name}{core::String}}"; | |
| } | |
| static method method1(self::Enum? e) → core::int { | |
| switch(e) /* self::Enum? */ { | |
| #L1: | |
| case #C3: | |
| case #C6: | |
| { | |
| return 0; | |
| } | |
| } | |
| return invalid-expression "pkg/front_end/testcases/nnbd/switch_nullable_enum.dart:9:5: Error: A non-null value must be returned since the return type 'int' doesn't allow null. | |
| int method1(Enum? e) { | |
| ^" in null; | |
| } | |
| static method method2(self::Enum? e) → core::int { | |
| switch(e) /* isExplicitlyExhaustive, self::Enum? */ { | |
| #L2: | |
| case #C3: | |
| case #C6: | |
| { | |
| return 0; | |
| } | |
| #L3: | |
| case #C8: | |
| { | |
| return 1; | |
| } | |
| } | |
| } | |
| static method method3(self::Enum? e) → core::int { | |
| switch(e) /* self::Enum? */ { | |
| #L4: | |
| case #C3: | |
| case #C6: | |
| { | |
| return 0; | |
| } | |
| #L5: | |
| default: | |
| { | |
| return 1; | |
| } | |
| } | |
| } | |
| static method method4(self::Enum? e) → core::int { | |
| switch(e) /* self::Enum? */ { | |
| #L6: | |
| case #C3: | |
| case #C6: | |
| { | |
| return 0; | |
| } | |
| #L7: | |
| case #C8: | |
| default: | |
| { | |
| return 1; | |
| } | |
| } | |
| } | |
| static method test() → dynamic { | |
| self::method1(#C3); | |
| } | |
| static method main() → dynamic { | |
| self::expect(0, self::method2(#C3)); | |
| self::expect(0, self::method2(#C6)); | |
| self::expect(1, self::method2(null)); | |
| self::expect(0, self::method3(#C3)); | |
| self::expect(0, self::method3(#C6)); | |
| self::expect(1, self::method3(null)); | |
| self::expect(0, self::method4(#C3)); | |
| self::expect(0, self::method4(#C6)); | |
| self::expect(1, self::method4(null)); | |
| } | |
| static method expect(dynamic expected, dynamic actual) → dynamic { | |
| if(!(expected =={core::Object::==}{(core::Object) → core::bool} actual)) { | |
| throw "Expected ${expected}, actual ${actual}."; | |
| } | |
| } | |
| constants { | |
| #C1 = 0 | |
| #C2 = "e1" | |
| #C3 = self::Enum {index:#C1, _name:#C2} | |
| #C4 = 1 | |
| #C5 = "e2" | |
| #C6 = self::Enum {index:#C4, _name:#C5} | |
| #C7 = <self::Enum>[#C3, #C6] | |
| #C8 = null | |
| } | |
| Constructor coverage from constants: | |
| org-dartlang-testcase:///switch_nullable_enum.dart: | |
| - Enum. (from org-dartlang-testcase:///switch_nullable_enum.dart:7:6) | |
| - _Enum. (from org-dartlang-sdk:///sdk/lib/core/enum.dart) | |
| - Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart) |