Skip to content

Conversation

@OndrejSpanel
Copy link
Contributor

@OndrejSpanel OndrejSpanel commented Sep 1, 2022

When a self alias is declared for a class, this.modify cannot be compiled, instead it results in error:

Unsupported source object: must be a case class or sealed trait, but got: val <none>

Code:

  case class State(x: Int) {self =>

    def mod: State = this.modify(_.x).setTo(1)
  }

This PR adds test demonstrating this issue.

It is quite likely the issue is closely related to #97

@OndrejSpanel
Copy link
Contributor Author

Note: the fix from #97 does not seem to have any effect on this issue.

@KacperFKorban
Copy link
Collaborator

Ok, I see what the issue is.
If we create a self type the type of this gets those 'refinements' added to its type. So obj.tpe.widen is an AndType in this case.

I can make a PR to fix it, but I'll wait for #97 to be merged, since it requires changes in similar places.

@adamw
Copy link
Member

adamw commented Sep 1, 2022

@KacperFKorban merged :)

@KacperFKorban
Copy link
Collaborator

I couldn't rebase this branch or push commits here. (since I don't have write access to the repo)
So I created a new PR and rebased it on top of this one -> #99

@OndrejSpanel OndrejSpanel deleted the pr-self-typed-this branch December 5, 2024 07:51
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.

3 participants