@@ -2536,107 +2536,6 @@ class ResolveTypeMembersAndFieldsWalk {
25362536 }
25372537 }
25382538
2539- void validateNonForcingIsA (core::Context ctx, const ast::Send &send) {
2540- constexpr string_view method = " T::NonForcingConstants.non_forcing_is_a?" ;
2541-
2542- if (send.numPosArgs () != 2 ) {
2543- return ;
2544- }
2545-
2546- auto numKwArgs = send.numKwArgs ();
2547- if (numKwArgs > 1 ) {
2548- return ;
2549- }
2550-
2551- auto stringLoc = send.getPosArg (1 ).loc ();
2552-
2553- auto literalNode = ast::cast_tree<ast::Literal>(send.getPosArg (1 ));
2554- if (literalNode == nullptr ) {
2555- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2556- e.setHeader (" `{}` only accepts string literals" , method);
2557- }
2558- return ;
2559- }
2560-
2561- if (!core::isa_type<core::NamedLiteralType>(literalNode->value )) {
2562- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2563- e.setHeader (" `{}` only accepts string literals" , method);
2564- }
2565- return ;
2566- }
2567-
2568- auto literal = core::cast_type_nonnull<core::NamedLiteralType>(literalNode->value );
2569- if (literal.kind != core::NamedLiteralType::Kind::String) {
2570- // Infer will report a type error
2571- return ;
2572- }
2573-
2574- auto shortName = literal.name .shortName (ctx);
2575- if (shortName.empty ()) {
2576- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2577- e.setHeader (" The string given to `{}` must not be empty" , method);
2578- }
2579- return ;
2580- }
2581-
2582- // If this string _begins_ with `::`, then the first fragment will be an empty string; in multiple places
2583- // below, we'll check to find out whether the first part is `""` or not, which means we're testing whether
2584- // the string did or did not begin with `::`.
2585- vector<string_view> parts = absl::StrSplit (shortName, " ::" );
2586-
2587- core::SymbolRef current;
2588- for (auto part : parts) {
2589- if (!current.exists ()) {
2590- current = core::Symbols::root ();
2591-
2592- // First iteration
2593- if (part != " " ) {
2594- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2595- e.setHeader (" The string given to `{}` must be an absolute constant reference that "
2596- " starts with `{}`" ,
2597- method, " ::" );
2598- }
2599- return ;
2600- }
2601- continue ;
2602- }
2603-
2604- auto member = ctx.state .lookupNameConstant (part);
2605- if (!member.exists ()) {
2606- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2607- auto prettyCurrent = current == core::Symbols::root () ? " " : " ::" + current.show (ctx);
2608- auto pretty = fmt::format (" {}::{}" , prettyCurrent, part);
2609- e.setHeader (" Unable to resolve constant `{}`" , pretty);
2610- }
2611- return ;
2612- }
2613-
2614- core::SymbolRef newCurrent;
2615- if (current.isClassOrModule ()) {
2616- newCurrent = current.asClassOrModuleRef ().data (ctx)->findMember (ctx, member);
2617- }
2618- if (!newCurrent.exists ()) {
2619- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2620- auto prettyCurrent = current == core::Symbols::root () ? " " : " ::" + current.show (ctx);
2621- auto pretty = fmt::format (" {}::{}" , prettyCurrent, part);
2622- e.setHeader (" Unable to resolve constant `{}`" , pretty);
2623- }
2624- return ;
2625- }
2626- current = newCurrent;
2627- }
2628-
2629- ENFORCE (current.exists (), " Loop invariant violated" );
2630-
2631- if (!current.isClassOrModule ()) {
2632- if (auto e = ctx.beginError (stringLoc, core::errors::Resolver::LazyResolve)) {
2633- e.setHeader (" The string given to `{}` must resolve to a class or module" , method);
2634- e.addErrorLine (current.loc (ctx), " Resolved to this constant" );
2635- }
2636- return ;
2637- }
2638- }
2639-
26402539 core::ClassOrModuleRef methodOwner (core::Context ctx) {
26412540 core::ClassOrModuleRef owner = ctx.owner .enclosingClass (ctx);
26422541 if (owner == core::Symbols::root ()) {
@@ -2868,9 +2767,6 @@ class ResolveTypeMembersAndFieldsWalk {
28682767 }
28692768 return ;
28702769 }
2871- case core::Names::nonForcingIsA_p ().rawId ():
2872- validateNonForcingIsA (ctx, send);
2873- return ;
28742770 default :
28752771 return ;
28762772 }
0 commit comments