Skip to content

Fix #3847: Handle correctly splicing of (possibly) nested type parameters #4116

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 20, 2018

Conversation

biboudis
Copy link
Contributor

Based on #4081

The proposed fix handle the case when a type splice e.g., ~t appears in possibly nested positions as a type parameter, e.g., List[~t] and List[Array[~t]]. If the code included just List[T] and List[Array[T]] the types are extracted and added as tags using implicit search in the phase of tryHeal. This commit collects and handles spliced types as well, using the same mechanism as before.

@nicolasstucki
Copy link
Contributor

@biboudis you can rebase on master and remove commit 87d364c (which is in PR #4103).

@biboudis biboudis force-pushed the fix-#3847-2 branch 2 times, most recently from c8affb6 to f7b179c Compare March 16, 2018 15:58
@nicolasstucki
Copy link
Contributor

val splicedType = tree.tpe.asInstanceOf[TypeRef].prefix.termSymbol
splice(ref(splicedType).select(tpnme.UNARY_~))
case tree: TypeApply =>
super.transform(tree)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we do not need this branch

Copy link
Contributor Author

Choose a reason for hiding this comment

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

True! Not anymore!

if (map.contains(tp))
map.apply(tp)
else
mapOver(tp)
Copy link
Contributor

Choose a reason for hiding this comment

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

Shorter and more efficient:

override def apply(tp: Type): Type = map.getOrElse(tp, mapOver(tp))

}
}

Block(typeDefs ++ tagsExplicitTypeDefsPairs.map(_._2),
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this just Block(typeDefs ++ explicitTypeDefs,?

@biboudis
Copy link
Contributor Author

Updated! Thanks for the review!

@nicolasstucki nicolasstucki merged commit 7cb10a8 into scala:master Mar 20, 2018
@allanrenucci allanrenucci deleted the fix-#3847-2 branch March 20, 2018 17:00
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.

2 participants