New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pigeon] Unable to generate code When a class field contains List<SelfClass?> #147454
Comments
The reason is that This can fix the issue // before
final Set<String> referencedTypeNames =
references.map.keys.map((TypeDeclaration e) => e.baseName).toSet();
for (final NamedType field in aClass.fields) {
if (_isUnseenCustomType(field.type, referencedTypeNames)) {
references.add(field.type, field.offset);
classesToCheck.add(field.type.baseName);
}
for (final TypeDeclaration typeArg in field.type.typeArguments) {
if (_isUnseenCustomType(typeArg, referencedTypeNames) ) {
references.add(typeArg, field.offset);
classesToCheck.add(typeArg.baseName);
}
}
}
// after
Set<String> referencedTypeNames = _getReferencedTypeNames(references);
for (final NamedType field in aClass.fields) {
if (_isUnseenCustomType(field.type, referencedTypeNames)) {
references.add(field.type, field.offset);
referencedTypeNames = _getReferencedTypeNames(references);
classesToCheck.add(field.type.baseName);
}
for (final TypeDeclaration typeArg in field.type.typeArguments) {
if (_isUnseenCustomType(typeArg, referencedTypeNames) ) {
references.add(typeArg, field.offset);
referencedTypeNames = _getReferencedTypeNames(references);
classesToCheck.add(typeArg.baseName);
}
}
}
Set<String> _getReferencedTypeNames(_Bag<TypeDeclaration, int> references) {
return references.map.keys.map((TypeDeclaration e) => e.baseName).toSet();
}
|
I've actually already found and fixed this bug in the pr I'm actively working on here flutter/packages#6600, so a working version should be up "soon" |
What package does this bug report belong to?
pigeon
What target platforms are you seeing this bug on?
Android
Have you already upgraded your packages?
Yes
Dependency versions
pubspec.lock
Steps to reproduce
dart run pigeon --input ./pigeon.dart
Expected results
generate target code
Actual results
code generator is freezed and nothing is output.
Code sample
pigeon_bug.zip
Screenshots or Videos
No response
Logs
No response
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: