From 40a07f9e6445a890a7dbd7684cc25605dcf4522c Mon Sep 17 00:00:00 2001 From: "Matthew \"strager\" Glazar" Date: Tue, 20 Aug 2024 02:57:28 -0400 Subject: [PATCH] refactor(fe): Diag_List_Diag_Reporter->Diag_List in Variable_Analyzer --- benchmark/benchmark-lint.cpp | 7 +-- src/quick-lint-js/fe/linter.cpp | 2 +- src/quick-lint-js/fe/variable-analyzer.cpp | 60 +++++++++---------- src/quick-lint-js/fe/variable-analyzer.h | 7 +-- .../variable-analyzer-support.cpp | 3 +- test/test-variable-analyzer-globals.cpp | 40 ++++++------- test/test-variable-analyzer-type.cpp | 40 ++++++------- 7 files changed, 75 insertions(+), 84 deletions(-) diff --git a/benchmark/benchmark-lint.cpp b/benchmark/benchmark-lint.cpp index 4e2552e82..ad31a5073 100644 --- a/benchmark/benchmark-lint.cpp +++ b/benchmark/benchmark-lint.cpp @@ -43,7 +43,7 @@ void benchmark_lint(benchmark::State &state) { for (auto _ : state) { Monotonic_Allocator memory("benchmark"); - Diag_List_Diag_Reporter diags(&memory); + Diag_List diags(&memory); Variable_Analyzer l(&diags, &config.globals(), var_options); visitor.copy_into(l); @@ -73,8 +73,7 @@ void benchmark_parse_and_lint(benchmark::State &state) { Configuration config; for (auto _ : state) { Parser p(&source, p_options); - Variable_Analyzer l(&p.diag_list_diag_reporter(), &config.globals(), - var_options); + Variable_Analyzer l(&p.diags(), &config.globals(), var_options); p.parse_and_visit_module(l); } } @@ -114,7 +113,7 @@ void benchmark_undeclared_variable_references(benchmark::State &state) { Variable_Analyzer_Options var_options; for (auto _ : state) { Monotonic_Allocator memory("benchmark"); - Diag_List_Diag_Reporter diags(&memory); + Diag_List diags(&memory); Variable_Analyzer l(&diags, &globals, var_options); for (Identifier &variable_use : variable_use_identifiers) { l.visit_variable_use(variable_use); diff --git a/src/quick-lint-js/fe/linter.cpp b/src/quick-lint-js/fe/linter.cpp index cdb6ee69a..54b42b3cb 100644 --- a/src/quick-lint-js/fe/linter.cpp +++ b/src/quick-lint-js/fe/linter.cpp @@ -45,7 +45,7 @@ void parse_and_lint(Padded_String_View code, Diag_Reporter& reporter, Parser p(code, parser_options); Variable_Analyzer var_analyzer( - &p.diag_list_diag_reporter(), &options.configuration->globals(), + &p.diags(), &options.configuration->globals(), Variable_Analyzer_Options{ .allow_deleting_typescript_variable = !parser_options.typescript, .eval_can_declare_variables = !parser_options.typescript, diff --git a/src/quick-lint-js/fe/variable-analyzer.cpp b/src/quick-lint-js/fe/variable-analyzer.cpp index 34664c67b..743a0148e 100644 --- a/src/quick-lint-js/fe/variable-analyzer.cpp +++ b/src/quick-lint-js/fe/variable-analyzer.cpp @@ -106,12 +106,9 @@ bool is_runtime_and_type(Variable_Kind); } Variable_Analyzer::Variable_Analyzer( - Diag_List_Diag_Reporter *diag_reporter, - const Global_Declared_Variable_Set *global_variables, + Diag_List *out_diags, const Global_Declared_Variable_Set *global_variables, Variable_Analyzer_Options options) - : global_scope_(global_variables), - diag_reporter_(diag_reporter), - options_(options) {} + : global_scope_(global_variables), diags_(out_diags), options_(options) {} void Variable_Analyzer::visit_enter_block_scope() { this->scopes_.push(); } @@ -438,10 +435,9 @@ void Variable_Analyzer::visit_variable_assertion_signature_use( if (var) { // FIXME(strager): Should we mark the parameter as used? } else { - this->diag_reporter_->report( - Diag_Use_Of_Undeclared_Parameter_In_Assertion_Signature{ - .name = name.span(), - }); + this->diags_->add(Diag_Use_Of_Undeclared_Parameter_In_Assertion_Signature{ + .name = name.span(), + }); } } @@ -464,7 +460,7 @@ void Variable_Analyzer::visit_variable_delete_use( this->add_variable_use_to_current_scope(std::move(used_var)); } } else { - this->diag_reporter_->report(Diag_TypeScript_Delete_Cannot_Delete_Variables{ + this->diags_->add(Diag_TypeScript_Delete_Cannot_Delete_Variables{ .delete_expression = Source_Code_Span(delete_keyword.begin(), name.span().end()), }); @@ -502,10 +498,9 @@ void Variable_Analyzer::visit_variable_type_predicate_use(Identifier name) { if (var) { // FIXME(strager): Should we mark the parameter as used? } else { - this->diag_reporter_->report( - Diag_Use_Of_Undeclared_Parameter_In_Type_Predicate{ - .name = name.span(), - }); + this->diags_->add(Diag_Use_Of_Undeclared_Parameter_In_Type_Predicate{ + .name = name.span(), + }); } } @@ -612,7 +607,7 @@ void Variable_Analyzer::visit_end_of_module() { if (!is_variable_declared(used_var)) { switch (used_var.kind) { case Used_Variable_Kind::assignment: - this->diag_reporter_->report(Diag_Assignment_To_Undeclared_Variable{ + this->diags_->add(Diag_Assignment_To_Undeclared_Variable{ .assignment = used_var.name.span()}); break; case Used_Variable_Kind::_delete: @@ -620,14 +615,14 @@ void Variable_Analyzer::visit_end_of_module() { // deletable. break; case Used_Variable_Kind::type: - this->diag_reporter_->report( + this->diags_->add( Diag_Use_Of_Undeclared_Type{.name = used_var.name.span()}); break; case Used_Variable_Kind::_export: case Used_Variable_Kind::_export_default: case Used_Variable_Kind::use: case Used_Variable_Kind::use_in_type: - this->diag_reporter_->report( + this->diags_->add( Diag_Use_Of_Undeclared_Variable{.name = used_var.name.span()}); break; case Used_Variable_Kind::_typeof: @@ -780,7 +775,7 @@ void Variable_Analyzer::propagate_variable_declarations_to_parent_scope() { (already_declared_variable->kind == Variable_Kind::_const || already_declared_variable->kind == Variable_Kind::_let || already_declared_variable->kind == Variable_Kind::_var)) { - this->diag_reporter_->report(Diag_Unused_Variable_Shadows{ + this->diags_->add(Diag_Unused_Variable_Shadows{ .shadowing_declaration = var.declaration.span(), .shadowed_declaration = already_declared_variable->declaration.span(), @@ -851,18 +846,18 @@ void Variable_Analyzer::report_error_if_assignment_is_illegal( case Variable_Kind::_import_alias: case Variable_Kind::_namespace: if (is_global_variable) { - this->diag_reporter_->report(Diag_Assignment_To_Const_Global_Variable{ + this->diags_->add(Diag_Assignment_To_Const_Global_Variable{ .assignment = assignment.span()}); } else { if (is_assigned_before_declaration) { - this->diag_reporter_->report( + this->diags_->add( Diag_Assignment_To_Const_Variable_Before_Its_Declaration{ .declaration = declaration->span(), .assignment = assignment.span(), .var_kind = kind, }); } else { - this->diag_reporter_->report(Diag_Assignment_To_Const_Variable{ + this->diags_->add(Diag_Assignment_To_Const_Variable{ .declaration = declaration->span(), .assignment = assignment.span(), .var_kind = kind}); @@ -879,7 +874,7 @@ void Variable_Analyzer::report_error_if_assignment_is_illegal( // HACK(#1141): Avoid false positives in TypeScript by disabling this // diagnostic for now. if (!this->options_.import_variable_can_be_runtime_or_type) { - this->diag_reporter_->report(Diag_Assignment_To_Imported_Variable{ + this->diags_->add(Diag_Assignment_To_Imported_Variable{ .declaration = declaration->span(), .assignment = assignment.span(), .var_kind = kind, @@ -895,7 +890,7 @@ void Variable_Analyzer::report_error_if_assignment_is_illegal( QLJS_WARNING_PUSH QLJS_WARNING_IGNORE_GCC("-Wnull-dereference") - this->diag_reporter_->report(Diag_Assignment_Before_Variable_Declaration{ + this->diags_->add(Diag_Assignment_Before_Variable_Declaration{ .assignment = assignment.span(), .declaration = declaration->span(), }); @@ -947,7 +942,7 @@ void Variable_Analyzer::report_errors_for_variable_use( used_var.kind == Used_Variable_Kind::_delete) { // TODO(strager): What if the variable was parenthesized? We should // include the closing parenthesis. - this->diag_reporter_->report(Diag_Redundant_Delete_Statement_On_Variable{ + this->diags_->add(Diag_Redundant_Delete_Statement_On_Variable{ .delete_expression = Source_Code_Span(used_var.delete_keyword_begin, used_var.name.span().end()), }); @@ -958,11 +953,10 @@ void Variable_Analyzer::report_errors_for_variable_use( declared.declaration_scope == Declared_Variable_Scope::declared_in_descendant_scope && used_var.kind == Used_Variable_Kind::use) { - this->diag_reporter_->report( - Diag_Function_Call_Before_Declaration_In_Block_Scope{ - .use = used_var.name.span(), - .declaration = declared.declaration.span(), - }); + this->diags_->add(Diag_Function_Call_Before_Declaration_In_Block_Scope{ + .use = used_var.name.span(), + .declaration = declared.declaration.span(), + }); } if (use_is_before_declaration) { @@ -981,7 +975,7 @@ void Variable_Analyzer::report_errors_for_variable_use( if (declared.kind == Variable_Kind::_class || declared.kind == Variable_Kind::_const || declared.kind == Variable_Kind::_let) { - this->diag_reporter_->report(Diag_Variable_Used_Before_Declaration{ + this->diags_->add(Diag_Variable_Used_Before_Declaration{ .use = used_var.name.span(), .declaration = declared.declaration.span(), }); @@ -995,7 +989,7 @@ void Variable_Analyzer::report_errors_for_variable_use( break; case Used_Variable_Kind::type: if (declared.kind == Variable_Kind::_generic_parameter) { - this->diag_reporter_->report(Diag_Variable_Used_Before_Declaration{ + this->diags_->add(Diag_Variable_Used_Before_Declaration{ .use = used_var.name.span(), .declaration = declared.declaration.span(), }); @@ -1220,11 +1214,11 @@ bool Variable_Analyzer::report_error_if_variable_declaration_conflicts( bool already_declared_is_global_variable = already_declared_var.name == nullptr; if (already_declared_is_global_variable) { - this->diag_reporter_->report(Diag_Redeclaration_Of_Global_Variable{ + this->diags_->add(Diag_Redeclaration_Of_Global_Variable{ .redeclaration = newly_declared_var.declaration.span(), }); } else { - this->diag_reporter_->report(Diag_Redeclaration_Of_Variable{ + this->diags_->add(Diag_Redeclaration_Of_Variable{ .redeclaration = newly_declared_var.declaration.span(), .original_declaration = already_declared_var.name->span(), }); diff --git a/src/quick-lint-js/fe/variable-analyzer.h b/src/quick-lint-js/fe/variable-analyzer.h index e65e39999..2e97a1763 100644 --- a/src/quick-lint-js/fe/variable-analyzer.h +++ b/src/quick-lint-js/fe/variable-analyzer.h @@ -12,8 +12,7 @@ #include namespace quick_lint_js { -class Diag_List_Diag_Reporter; -class Diag_Reporter; +class Diag_List; class Global_Declared_Variable_Set; struct Global_Declared_Variable; @@ -57,7 +56,7 @@ struct Variable_Analyzer_Options { class Variable_Analyzer final : public Parse_Visitor_Base { public: explicit Variable_Analyzer( - Diag_List_Diag_Reporter *diag_reporter, + Diag_List *out_diags, const Global_Declared_Variable_Set *global_variables, Variable_Analyzer_Options options); @@ -415,7 +414,7 @@ class Variable_Analyzer final : public Parse_Visitor_Base { // with the 'declare' keyword. unsigned typescript_ambient_context_depth_ = 0; - Diag_Reporter *diag_reporter_; + Diag_List *diags_; Variable_Analyzer_Options options_; }; diff --git a/test/quick-lint-js/variable-analyzer-support.cpp b/test/quick-lint-js/variable-analyzer-support.cpp index 2c2a02c7f..79f461299 100644 --- a/test/quick-lint-js/variable-analyzer-support.cpp +++ b/test/quick-lint-js/variable-analyzer-support.cpp @@ -61,8 +61,7 @@ void test_parse_and_analyze(String8_View input, Padded_String code(input); Parser p(&code, options.parse_options); - Variable_Analyzer var_analyzer(&p.diag_list_diag_reporter(), &globals, - options.analyze_options); + Variable_Analyzer var_analyzer(&p.diags(), &globals, options.analyze_options); p.parse_and_visit_module(var_analyzer); assert_diagnostics(&code, p.diags(), diag_assertions, caller); diff --git a/test/test-variable-analyzer-globals.cpp b/test/test-variable-analyzer-globals.cpp index 697f04093..5813ee663 100644 --- a/test/test-variable-analyzer-globals.cpp +++ b/test/test-variable-analyzer-globals.cpp @@ -202,23 +202,23 @@ TEST_F(Test_Variable_Analyzer_Globals, global_variables_are_usable) { // Array; for (const Char8 *global_variable : writable_global_variables) { SCOPED_TRACE(out_string8(global_variable)); - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_variable_assignment(identifier_of(global_variable), Variable_Assignment_Flags::none); l.visit_variable_use(identifier_of(global_variable)); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } // NaN; for (const Char8 *global_variable : non_writable_global_variables) { SCOPED_TRACE(out_string8(global_variable)); - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_variable_use(identifier_of(global_variable)); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } } @@ -228,14 +228,14 @@ TEST_F(Test_Variable_Analyzer_Globals, SCOPED_TRACE(out_string8(global_variable)); // NaN = null; // ERROR - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_variable_assignment(identifier_of(global_variable), Variable_Assignment_Flags::none); l.visit_end_of_module(); auto *diag = get_only_diagnostic( - diags.diags(), Diag_Type::Diag_Assignment_To_Const_Global_Variable); + diags, Diag_Type::Diag_Assignment_To_Const_Global_Variable); ASSERT_NE(diag, nullptr); EXPECT_TRUE(same_pointers(diag->assignment, span_of(global_variable))); } @@ -246,7 +246,7 @@ TEST_F(Test_Variable_Analyzer_Globals, // (() => { // NaN = null; // ERROR // }); - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_enter_function_scope(); l.visit_enter_function_scope_body(); @@ -256,7 +256,7 @@ TEST_F(Test_Variable_Analyzer_Globals, l.visit_end_of_module(); auto *diag = get_only_diagnostic( - diags.diags(), Diag_Type::Diag_Assignment_To_Const_Global_Variable); + diags, Diag_Type::Diag_Assignment_To_Const_Global_Variable); ASSERT_NE(diag, nullptr); EXPECT_TRUE(same_pointers(diag->assignment, span_of(global_variable))); } @@ -265,11 +265,11 @@ TEST_F(Test_Variable_Analyzer_Globals, TEST_F(Test_Variable_Analyzer_Globals, nodejs_global_variables_are_usable) { for (const Char8 *global_variable : nodejs_global_variables) { SCOPED_TRACE(out_string8(global_variable)); - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_variable_use(identifier_of(global_variable)); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } } @@ -278,7 +278,7 @@ TEST_F(Test_Variable_Analyzer_Globals, for (Variable_Declaration_Flags flags : {Variable_Declaration_Flags::none, Variable_Declaration_Flags::initialized_with_equals}) { - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); // Intentionally excluded: __dirname, __filename, exports, module, require for (const Char8 *global_variable : nodejs_global_variables) { @@ -287,7 +287,7 @@ TEST_F(Test_Variable_Analyzer_Globals, } l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } } @@ -298,25 +298,25 @@ TEST_F(Test_Variable_Analyzer_Globals, // Awaited; { - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, typescript_var_options); l.visit_variable_use(identifier_of(global_variable)); l.visit_end_of_module(); auto *diag = get_only_diagnostic( - diags.diags(), Diag_Type::Diag_Use_Of_Undeclared_Variable); + diags, Diag_Type::Diag_Use_Of_Undeclared_Variable); ASSERT_NE(diag, nullptr); EXPECT_TRUE(same_pointers(diag->name, span_of(global_variable))); } // Awaited = null; { - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, typescript_var_options); l.visit_variable_assignment(identifier_of(global_variable), Variable_Assignment_Flags::none); l.visit_end_of_module(); auto *diag = get_only_diagnostic( - diags.diags(), Diag_Type::Diag_Assignment_To_Undeclared_Variable); + diags, Diag_Type::Diag_Assignment_To_Undeclared_Variable); ASSERT_NE(diag, nullptr); EXPECT_TRUE(same_pointers(diag->assignment, span_of(global_variable))); } @@ -328,11 +328,11 @@ TEST_F(Test_Variable_Analyzer_Globals, // null as Awaited; for (const Char8 *global_variable : type_only_global_variables) { SCOPED_TRACE(out_string8(global_variable)); - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &default_globals, typescript_var_options); l.visit_variable_type_use(identifier_of(global_variable)); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } } @@ -348,7 +348,7 @@ TEST_F(Test_Variable_Analyzer_Globals, const Char8 anything_1_declaration[] = u8"thisVariableDoesNotExistInAnyList"; const Char8 anything_2_use[] = u8"iDoNotExistInAnyList"; - Diag_List_Diag_Reporter diags(&this->memory_); + Diag_List diags(&this->memory_); Variable_Analyzer l(&diags, &globals, javascript_var_options); l.visit_variable_declaration(identifier_of(builtin_1_declaration), Variable_Kind::_let, @@ -360,7 +360,7 @@ TEST_F(Test_Variable_Analyzer_Globals, l.visit_variable_use(identifier_of(anything_2_use)); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } } } diff --git a/test/test-variable-analyzer-type.cpp b/test/test-variable-analyzer-type.cpp index 683ec7c6f..24e94ab52 100644 --- a/test/test-variable-analyzer-type.cpp +++ b/test/test-variable-analyzer-type.cpp @@ -412,7 +412,7 @@ TEST(Test_Variable_Analyzer_Type, { // interface I {} // I; // ERROR - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(declaration), Variable_Kind::_interface, @@ -420,7 +420,7 @@ TEST(Test_Variable_Analyzer_Type, visit_kind.visit(l); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), std::nullopt); + visit_kind.check_diagnostics(v, std::nullopt); } { @@ -428,7 +428,7 @@ TEST(Test_Variable_Analyzer_Type, // { // I; // ERROR // } - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(declaration), Variable_Kind::_interface, @@ -438,7 +438,7 @@ TEST(Test_Variable_Analyzer_Type, l.visit_exit_block_scope(); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), std::nullopt); + visit_kind.check_diagnostics(v, std::nullopt); } { @@ -448,7 +448,7 @@ TEST(Test_Variable_Analyzer_Type, // I; // ERROR // }); // }); - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(declaration), Variable_Kind::_interface, @@ -462,7 +462,7 @@ TEST(Test_Variable_Analyzer_Type, l.visit_exit_function_scope(); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), std::nullopt); + visit_kind.check_diagnostics(v, std::nullopt); } for (Variable_Kind outer_kind : { @@ -483,7 +483,7 @@ TEST(Test_Variable_Analyzer_Type, // interface I {} // I; // } - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(outer_declaration), outer_kind, @@ -496,7 +496,7 @@ TEST(Test_Variable_Analyzer_Type, l.visit_exit_block_scope(); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), outer_kind); + visit_kind.check_diagnostics(v, outer_kind); } { @@ -505,7 +505,7 @@ TEST(Test_Variable_Analyzer_Type, // { // I; // } - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(outer_declaration), outer_kind, @@ -518,14 +518,14 @@ TEST(Test_Variable_Analyzer_Type, l.visit_exit_block_scope(); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), outer_kind); + visit_kind.check_diagnostics(v, outer_kind); } { // let I; // interface I {} // I; - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(outer_declaration), outer_kind, @@ -536,14 +536,14 @@ TEST(Test_Variable_Analyzer_Type, visit_kind.visit(l); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), outer_kind); + visit_kind.check_diagnostics(v, outer_kind); } { // interface I {} // let I; // I; - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(declaration), Variable_Kind::_interface, @@ -554,7 +554,7 @@ TEST(Test_Variable_Analyzer_Type, visit_kind.visit(l); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), outer_kind); + visit_kind.check_diagnostics(v, outer_kind); } { @@ -563,7 +563,7 @@ TEST(Test_Variable_Analyzer_Type, // }); // interface I {} // let I; - Diag_List_Diag_Reporter v(&memory); + Diag_List v(&memory); Variable_Analyzer l(&v, &default_globals, javascript_var_options); l.visit_enter_function_scope(); l.visit_enter_function_scope_body(); @@ -577,7 +577,7 @@ TEST(Test_Variable_Analyzer_Type, Variable_Declaration_Flags::none); l.visit_end_of_module(); - visit_kind.check_diagnostics(v.diags(), outer_kind); + visit_kind.check_diagnostics(v, outer_kind); } } } @@ -606,7 +606,7 @@ TEST(Test_Variable_Analyzer_Type, mixing_non_type_and_type_only_is_okay) { { // interface C {} // let C; - Diag_List_Diag_Reporter diags(&memory); + Diag_List diags(&memory); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(type_declaration), type_declaration_kind, @@ -616,13 +616,13 @@ TEST(Test_Variable_Analyzer_Type, mixing_non_type_and_type_only_is_okay) { Variable_Declaration_Flags::none); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } { // let C; // interface C {} - Diag_List_Diag_Reporter diags(&memory); + Diag_List diags(&memory); Variable_Analyzer l(&diags, &default_globals, javascript_var_options); l.visit_variable_declaration(identifier_of(non_type_declaration), non_type_declaration_kind, @@ -632,7 +632,7 @@ TEST(Test_Variable_Analyzer_Type, mixing_non_type_and_type_only_is_okay) { Variable_Declaration_Flags::none); l.visit_end_of_module(); - EXPECT_THAT(diags.diags(), IsEmpty()); + EXPECT_THAT(diags, IsEmpty()); } } }