Skip to content
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

Improve New/Select -Ycheck message #16746

Merged
merged 1 commit into from
Feb 16, 2023
Merged

Conversation

nicolasstucki
Copy link
Contributor

We mention that the constructor must be selected. This should be all the information needed in case someone writes a buggy macro that does not include the Select around the New.

Closed #16357

We mention that the constructor must be selected. This should be all the
information needed in case someone writes a buggy macro that does not
include the `Select` around the `New`.

Closed scala#16357
@@ -141,7 +141,7 @@ class TreeChecker extends Phase with SymTransformer {
override def apply(parent: Tree, tree: Tree)(using Context): Tree = {
tree match {
case tree: New if !parent.isInstanceOf[tpd.Select] =>
assert(assertion = false, i"`New` node must be wrapped in a `Select`:\n parent = ${parent.show}\n child = ${tree.show}")
assert(assertion = false, i"`New` node must be wrapped in a `Select` of the constructor:\n parent = ${parent.show}\n child = ${tree.show}")
Copy link
Member

Choose a reason for hiding this comment

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

Maybe the message could mention how to do this for the reflection API? Is there an equivalent to nme.CONSTRUCTOR? Or a convenience method? Also maybe we should also check that if a Select exists, then the name selected has isConstructorName return true.

@nicolasstucki nicolasstucki merged commit ce1ca44 into scala:main Feb 16, 2023
@nicolasstucki nicolasstucki deleted the fix-16357 branch February 16, 2023 14:53
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.

Unexpected New (...) reached GenBCode
2 participants