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
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/TreeChecker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.

case _: Annotated =>
// Don't check inside annotations, since they're allowed to contain
// somewhat invalid trees.
Expand Down