Repository navigation
A written this: on a method annotates the receiver, it is not a parameter - #379
Merged
Merged
Conversation
…eter mlirGenParameters adds the implicit receiver of a class, interface or object-literal method, and then added the written `this:` parameter as another slot. The signature carried the receiver twice, and a call with the right number of arguments failed the arity check: "Expected 3 arguments, but got 2" (#342). The written `this` is now skipped when an implicit receiver is already there. Free and extension functions, which have no implicit receiver, keep their `this:` as before. Fixes #342 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #342. A method with a written
this:parameter carried its receiver twice in its signature:The signature came out as
!ts.func<!ts.class<@O>, !ts.class<@O>, number, number, number>.Cause
mlirGenParametersfirst adds the implicit receiver. That is an opaquethisfor an interface method, andgenContext.thisTypefor a class method, an object-literal method, or a function expression with athisType. The loop over the written parameters then treatedthislike any other parameter and added a second slot.Fix
When the parameter list already starts with the implicit receiver, the written
thisis skipped. The receiver keeps its implicit type, and the annotation does not replace it:{ x: number }it was annotated with.this: I) still gets the class.Free and extension functions have no implicit receiver, so their written
thisis still the receiver they bind. That path is unchanged, and it covers everythis:in TypeScriptCompilerDefaultLib.Tests
00method_this_param.ts(compile, jit, and the rc/none corpus). It covers a class method, an interface method implemented by a class and called through the interface, an object-literal method, and an extension function as a control.call-arity/method_this.ts: a short call now reportsExpected 2 arguments, but got 1.It used to say "3 … got 1".Not in this PR
getSignature(MLIRGenTypes.cpp), which builds type-literal and function-type signatures, still keeps a writtenthisas an ordinary parameter.00lambdas.tsis a different feature and stays commented out.🤖 Generated with Claude Code