Repository navigation
Closed
Labels
P0Critical issues such as a build break or regressionCritical issues such as a build break or regressionp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
Description
No crash:
import 'package:pigeon/pigeon.dart';
class Book {
String title;
String subtitle;
String author;
String publishDate;
int pageCount;
// Thumbnail thumbnail;
}
// class Thumbnail {
// String url;
// }
@HostApi()
abstract class HostBookApi {
Book getEditedBook();
}Crash:
import 'package:pigeon/pigeon.dart';
class Book {
String title;
String subtitle;
String author;
String publishDate;
int pageCount;
Thumbnail thumbnail;
}
class Thumbnail {
String url;
}
@HostApi()
abstract class HostBookApi {
Book getEditedBook();
}from running
flutter pub run pigeon --input pigeon/idl.dart --dart_out lib/api.dart --java_out ../android_books/app/src/main/java/dev/flutter/example/books/Api.java --java_package "dev.flutter.example.books"
Unhandled exception:
NoSuchMethodError: The getter 'datatype' was called on null.
Receiver: null
Tried calling: datatype
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:51:5)
#1 generateJava.<anonymous closure>.<anonymous closure> (package:pigeon/java_generator.dart:224:50)
#2 Indent.scoped (package:pigeon/generator_tools.dart:71:9)
#3 generateJava.<anonymous closure> (package:pigeon/java_generator.dart:220:14)
#4 Indent.scoped (package:pigeon/generator_tools.dart:71:9)
#5 generateJava (package:pigeon/java_generator.dart:214:10)
#6 Pigeon.run.<anonymous closure> (package:pigeon/pigeon_lib.dart:364:17)
#7 Pigeon._runGenerator (package:pigeon/pigeon_lib.dart:270:9)
#8 Pigeon.run (package:pigeon/pigeon_lib.dart:361:15)
<asynchronous suspension>
#9 main (file:///Users/xster/development/samples/add_to_app/flutter_module_books/_pigeon_temp_.dart:7:21)
#10 _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#11 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
cc @gaaclarke
Metadata
Metadata
Assignees
Labels
P0Critical issues such as a build break or regressionCritical issues such as a build break or regressionp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.
Activity
xster commentedon Jun 8, 2020
looking at the current list for pigeon, I think this one is likely the highest priority? WDYT?
gaaclarke commentedon Jun 12, 2020
This is an ordering issue because Thumbnail is used before it is defined. That's not how Dart typically works so I'll see if I can make the parser smarter.
[-][pigeon] java generator crashes when using nested class[/-][+][pigeon] crash when using a nested class before it is defined[/+]xster commentedon Jun 12, 2020
You're saying if I flipped the definition it would work? :D
gaaclarke commentedon Jun 12, 2020
Yep, i'm also going to make that error easier to understand in case someone mistypes a class name.
xster commentedon Jun 12, 2020
That's just #58897 right?
gaaclarke commentedon Jun 12, 2020
@xster Yep, should be. I'm going to cover it to be sure.
gaaclarke commentedon Jun 12, 2020
Wait i'm wrong about the ordering, my bad. I saw one work in the other order and I... assumed :*(
gaaclarke commentedon Jun 12, 2020
This is the actual issue,
Thumbnailis never referenced in the API directly so it isn't parsed, this works:I just have to make the parsing of nested classes recurse.
[-][pigeon] crash when using a nested class before it is defined[/-][+][pigeon] crash using a nested class who isn't referenced in an API directly[/+]github-actions commentedon Aug 20, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.