Skip to content

Commit

Permalink
Handle const string errors from composer plugin methods
Browse files Browse the repository at this point in the history
Summary: Composer plugin methods use `""` as the default value for the fields, which we will allow since the setter methods are annotated

Reviewed By: thezhangwei

Differential Revision: D63798066

fbshipit-source-id: c65c6252ec708c31b315c871fb0bf65e7db4ad53
  • Loading branch information
itang00 authored and facebook-github-bot committed Oct 21, 2024
1 parent 58daa96 commit 7011e20
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions opt/typedef-anno-checker/TypedefAnnoCheckerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ bool is_model_gen(const DexMethod* m) {
return false;
}

bool is_composer_generated(const DexMethod* m) {
DexType* type = m->get_class();
DexClass* cls = type_class(type);
if (!cls->get_anno_set()) {
return false;
}
DexAnnotation* anno = get_annotation(
cls, DexType::make_type(
"Lcom/facebook/xapp/messaging/composer/annotation/Generated;"));
if (anno) {
return true;
}
return false;
}

bool has_kotlin_default_ctor_marker(DexMethod* m) {
auto params = m->get_proto()->get_args();
if (params->size() > 1 &&
Expand Down Expand Up @@ -1443,6 +1458,9 @@ bool TypedefAnnoChecker::check_typedef_value(
switch (def->opcode()) {
case OPCODE_CONST_STRING: {
auto const const_value = def->get_string();
if (const_value->str().empty() && is_composer_generated(m)) {
break;
}
if (str_value_set->count(const_value) == 0) {
std::ostringstream out;
out << "TypedefAnnoCheckerPass: in method " << show(m)
Expand Down

0 comments on commit 7011e20

Please sign in to comment.