Skip to content

Conversation

@som-snytt
Copy link
Contributor

Fixes #24375

The original name can be recovered for messages.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The approach looks workable to me. The test failures seem to come from this part in Message.scala:

    override def ParamRefNameString(param: ParamRef): String =
      seen.record(super.ParamRefNameString(param), param.isInstanceOf[TypeParamRef], param)

Maybe we can try to just turn off seen.record here, i.e. drop the whole def? I am not sure more explanations of parameter names help. But one has to try it out and look at the changes.

@som-snytt som-snytt force-pushed the issue/24375-context-function-param-names branch from 73533af to dab9edb Compare November 12, 2025 10:36
@som-snytt
Copy link
Contributor Author

Just a stop-gap update. I will revisit the parameter disambiguation.

Now it is aware that the written l and the inferred lcontextual$1 are not the same. Or maybe just let it ignore the difference.

def withFile[T](op: (l: caps.Capability) ?-> (f: File^{l}) => T): T =
  op(using caps.cap)(new File)

def test =
  withFile: f =>       // error with level checking, was OK under both schemes before
    val o = Service()
    o.file = f
    o.log

@odersky
Copy link
Contributor

odersky commented Nov 12, 2025

I think @Sporarum's comment on the issue makes sense.

protected def ParamRefNameString(param: ParamRef): String =
ParamRefNameString(param.binder.paramNames(param.paramNum))
val name = param.binder.paramNames(param.paramNum)
ParamRefNameString:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Answering @Sporarum's comment on the issue :
#24375 (comment)

Maybe we should work on the toString function for ContectFunctionParamNames instead of intervening here.

@som-snytt som-snytt force-pushed the issue/24375-context-function-param-names branch from e0a5939 to cbc28fc Compare November 16, 2025 08:15
@som-snytt
Copy link
Contributor Author

The captures tests start to fail in the presence of java.lang.IO because of the constructor proxy shadowing rule.

There are other failing tests on recent JDKs because of the way lambdas are printed, etc.

@som-snytt som-snytt force-pushed the issue/24375-context-function-param-names branch from cbc28fc to 88af888 Compare November 16, 2025 17:07
@som-snytt som-snytt marked this pull request as ready for review November 17, 2025 20:31
@som-snytt
Copy link
Contributor Author

Pushed the same "fix" downstack, but I haven't given any thought to what is desirable in a superscript, or whether other kinds would benefit from similar tweaking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Context function parameter name leaks into scope

2 participants