Skip to content

Fix specialization of methods with dependent return types#9652

Merged
lrytz merged 1 commit intoscala:2.13.xfrom
joroKr21:dependent-specialization
Jun 2, 2021
Merged

Fix specialization of methods with dependent return types#9652
lrytz merged 1 commit intoscala:2.13.xfrom
joroKr21:dependent-specialization

Conversation

@joroKr21
Copy link
Member

@joroKr21 joroKr21 commented Jun 1, 2021

Substitute both type and value parameter symbols in return type

Fixes scala/bug#12210

Substitute both type and value parameter symbols in return type
@scala-jenkins scala-jenkins added this to the 2.13.7 milestone Jun 1, 2021
@joroKr21 joroKr21 marked this pull request as ready for review June 1, 2021 17:20
val substituter = new ImplementationAdapter(srcParams, newParams, source.enclClass, false)
val newRhs = substituter(body(source).duplicate)
tpt.modifyType(_.substSym(oldParams, newParams))
copyDefDef(tree)(vparamss = newVparams.map(ValDef.apply) :: Nil, rhs = newRhs)
Copy link
Member

Choose a reason for hiding this comment

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

I can't spot it after squinting a bit at it... where's the fix?

Copy link
Member Author

@joroKr21 joroKr21 Jun 2, 2021

Choose a reason for hiding this comment

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

In tpt.modifyType(_.substSym(oldParams, newParams)) where xParams = xVparams ::: xTparams - I've extracted the intermediate variables to make it more readable because it's confusing with 3 sets of parameters.

Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

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

LGTM

@lrytz lrytz merged commit f74ccec into scala:2.13.x Jun 2, 2021
@joroKr21 joroKr21 deleted the dependent-specialization branch June 3, 2021 18:37
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.

Specialization + dependent method type --> inconsistent symbols

4 participants