google / google/reflectable.dart

Generated code references private class constructor which leads to compile error

Open
#351 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
386
Forks
67
PR merge metrics
No merged PRs in 30d

Description

Reflectable should either handle private classes gracefully or somehow ignore them.

When I generate for my project Reflectable somehow includes the _StringStacktrace class from dart.core:

r.NonGenericClassMirrorImpl(
r'_StringStackTrace',
r'dart.core._StringStackTrace',
134217767,
80,
const prefix0.TomReflector(),
const [1192, 1193],
const [162, 1192, 164, 165, 166],
const [],
41,
{},
{},
{
r'': (bool b) =>
(_stackTrace) => b ? _StringStackTrace(_stackTrace) : null,
},
14, ...

The line

(_stackTrace) => b ? _StringStackTrace(_stackTrace) : null,

results in a compiler error "The function '_StringStackTrace' isn't defined."

I got this specific case several times in different projects, but it obviously depends on what parts of the dare libraries are used. I actually haven't figured out what exactly trigger this problem. I also got a similar error once from one of my classes which I resolved by changing the classname to not have the underscore prefix.

As I'm generating not automatically to save time by only generating from time to time I can simply fix this manually every time I generate, but this doesn't sound like a final solution to me.

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.