Skip to content

ConstantReader.revive() crashes when attempting to revive a type #411

Open
@jbdeboer

Description

@jbdeboer

e.g. Adding a test to constants_test.dart:

@TypeWrapper(String)
class Example {}

class TypeWrapper {
  final Type t;
  const TypeWrapper(this.t);
}

test('should not crash when resolving types', () {
  expect(typeWrapperConstant.read('t').revive(), isNull /* or anything */)
});

throws the following:

  Bad state: No element
  dart:core                                                               List.first
  package:source_gen/src/constants/revive.dart 97:21                      reviveInstance
  package:source_gen/src/constants/reader.dart 276:25                     _DartObjectConstant.revive
  test/constants_test.dart 356:49  main.<fn>.<fn>

I don't know what the correct behaviour is, but I know the code should not crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions