google / google/built_value.dart

Compute required imports, check for them

Open
#1,020 2 comments 0 reactions 1 assignee Claimed by @davidmorgan View on GitHub
p2 / feature request
Dominant language
Dart
Stars
886
Forks
195
Avg merge
1d 11h
Merged PRs (30d)
4

Description

This doesn't seem to compile:

```dart
// legs.dart
// external class referenced from animal.dart, but not from cat.dart
class Legs {}

// animal.dart
import 'legs.dart';

abstract class Animal {
Legs get legs;
}

// cat.dart
import 'animal.dart';

part 'cat.g.dart';

abstract class Cat implements Built, Animal {
bool get tail;

Cat._();
factory Cat([void Function(CatBuilder) updates]) = _$Cat;
}
```

Since `cat.dart` doesn't reference `legs.dart` class, neither does the `cat.g.dart`. So when it would try to compile `cat.g.dart`, it will fail with something like

```
ERROR: cat.g.dart
final Legs legs; Undefined class. #undefined_class
```

The workaround seems to re-export 'legs.dart' from 'animal.dart', or force import 'legs.dart' in 'animal.dart'.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.