| library /*isNonNullableByDefault*/; |
| // |
| // Problems in library: |
| // |
| // pkg/front_end/testcases/nnbd/switch_nullable_enum.dart:7: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::Object /*isEnum*/ { |
| final field core::int index; |
| final field core::String _name; |
| static const field core::List<self::Enum> values = #C7; |
| static const field self::Enum e1 = #C3; |
| static const field self::Enum e2 = #C6; |
| const constructor •(core::int index, core::String _name) → self::Enum |
| : self::Enum::index = index, self::Enum::_name = _name, super core::Object::•() |
| ; |
| method toString() → core::String |
| return this.{self::Enum::_name}{core::String}; |
| } |
| static method method1(self::Enum? e) → core::int { |
| switch(e) { |
| #L1: |
| case #C3: |
| case #C6: |
| { |
| return 0; |
| } |
| } |
| return let final Never #t1 = invalid-expression "pkg/front_end/testcases/nnbd/switch_nullable_enum.dart:7: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) { |
| #L2: |
| case #C3: |
| case #C6: |
| { |
| return 0; |
| } |
| #L3: |
| case #C8: |
| { |
| return 1; |
| } |
| } |
| } |
| static method method3(self::Enum? e) → core::int { |
| switch(e) { |
| #L4: |
| case #C3: |
| case #C6: |
| { |
| return 0; |
| } |
| #L5: |
| default: |
| { |
| return 1; |
| } |
| } |
| } |
| static method method4(self::Enum? e) → core::int { |
| switch(e) { |
| #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 = "Enum.e1" |
| #C3 = self::Enum {index:#C1, _name:#C2} |
| #C4 = 1 |
| #C5 = "Enum.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:5:6) |
| - Object. (from org-dartlang-sdk:///sdk/lib/core/object.dart:25:9) |