Repository navigation
Conversation
RBS declares Class#new as (*untyped) -> untyped because RBS cannot parameterize Class. ApiMap#get_methods already replaces that pin with a self-returning synthesis for concrete namespaces, but deliberately skips rooted_tag Class / Class<Class>, leaving untyped - so Class.new.new and k.new (k: bare Class) were uninferrable. Proxy the pin instead: scope :class (literal Class.new) -> Class<Object> (the default-superclass anonymous class), scope :instance (.new on an unparameterized Class-typed receiver) -> Object (some instance of an unknown class). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H1FEjW6nMpZrWPmeWX9miT
For a receiver typed Class<generic<T>>, singleton-method lookup runs against the nonexistent 'generic' namespace, so no Class#new pin ever appears and .new goes undefined - even though the instance type is exactly the generic the caller binds. Synthesize a permissive new pin (restarg/kwrestarg, since the real initializer is unknown) returning the generic tag itself. Caller-side binding already worked; this fixes the method-body side. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01H1FEjW6nMpZrWPmeWX9miT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claude: This PR was written by Claude Code on behalf of @apiology.
Problem:
Methods returning
.newon aClass-typed value fail strong typecheck:Each such method needs an
@sg-ignoreat its definition; callers are unaffected, since they use the declared@return.Solution:
Types
Class.newasClass<Object>and.newon any other bareClassvalue asObject, and givesClass<generic<T>>anewreturninggeneric<T>with arguments unchecked, since its initializer is unknown.define_methodinside the block is castwide#1310's to fix.