class are converted to abstract class when building in AOT mode, how to avoid?

18 views
Skip to first unread message

Jim Xu

unread,
Sep 16, 2019, 7:55:49 AM9/16/19
to Dart Compiler Developers
I declare a class but only use its type, and it finally built as abstract class without constructor. I know it might be caused by tree shaking. Can I avoid it not using @pragma("vm:entry-point")?
Thanks in advance.

here is my codes:
//class will changed to abstract class
class UserData {
  String name;
  String city;
  int age;
  // @serialize(alias:xxx)
  double squares;
  bool sex;
  List<Child> children;
  Map<StringString> houses;
  Child child;
  DateTime birthday;
  UserData son;
  Map<DateTimeString> test1;
  Map<intString> test2;

  //the constructor will be stripped
  UserData();

}

void main(){
UserData userData = JsonDrill.fromJson<UserData>(jsonDecode(str));
    var map = JsonDrill.toJson<UserData>(userData);
    String result = "----toJson---$map---";
}

Jim Xu

unread,
Sep 17, 2019, 2:58:24 AM9/17/19
to Dart Compiler Developers
anybody help, thanks

Johnni Winther

unread,
Sep 17, 2019, 3:21:24 AM9/17/19
to Jim Xu, Dart Compiler Developers, Martin Kustermann
+ kustermann@

How are you compiling the program? For AOT or with dart2js?

--
To unsubscribe from this group and stop receiving emails from it, send an email to compiler-dev...@dartlang.org.

Jim Xu

unread,
Sep 18, 2019, 2:03:00 AM9/18/19
to Dart Compiler Developers, xujia...@gmail.com, kuste...@google.com
Thanks for reply.
I compile it for AOT
To unsubscribe from this group and stop receiving emails from it, send an email to compil...@dartlang.org.

Vyacheslav Egorov

unread,
Sep 18, 2019, 5:30:14 AM9/18/19
to Jim Xu, Dart Compiler Developers, Martin Kustermann
Hi!

Do I understand correctly that you do some custom transformation over the Kernel representation of your program? 

In this case it would be best to embed these transformations into the pipeline *before* TFA is run - not after.

It needs to happen approximately at this point: https://github.com/dart-lang/sdk/blob/master/pkg/vm/lib/kernel_front_end.dart#L347

// Vyacheslav Egorov


To unsubscribe from this group and stop receiving emails from it, send an email to compiler-dev...@dartlang.org.

Jim Xu

unread,
Sep 19, 2019, 12:15:39 AM9/19/19
to Dart Compiler Developers, xujia...@gmail.com, kuste...@google.com
Vyacheslav,
Thank you very much, I got it. Please allow me ask the second question: Will CFE or flutter tool provide a mechanism(pipe line) for customizing/embedding these transformation before TFA? Has it been in flutter's plate?
To unsubscribe from this group and stop receiving emails from it, send an email to compil...@dartlang.org.

Vyacheslav Egorov

unread,
Sep 19, 2019, 5:01:17 AM9/19/19
to Jim Xu, Dart Compiler Developers, Martin Kustermann
So far we were shying away from this - because transforming kernel requires good knowledge of some internals.

However given that this is rising in popularity - we should consider exposing this in a better way. 

I will raise this question internally. 

// Vyacheslav Egorov


To unsubscribe from this group and stop receiving emails from it, send an email to compiler-dev...@dartlang.org.

Jim Xu

unread,
Sep 20, 2019, 5:36:41 AM9/20/19
to Dart Compiler Developers, xujia...@gmail.com, kuste...@google.com
Gotcha, thanks
To unsubscribe from this group and stop receiving emails from it, send an email to compil...@dartlang.org.
Reply all
Reply to author
Forward
0 new messages