Skip to content

Conversation

hamzaremmal
Copy link
Member

Closes #23901

@sjrd sjrd disabled auto-merge September 12, 2025 09:42
Copy link
Member

@sjrd sjrd left a comment

Choose a reason for hiding this comment

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

LGTM after giving a better name to isGenericArray.


@main def Test =
val arr: Array[Array[String]] = MyArray.empty[String]
assert(arr.length == 0)
Copy link
Member

Choose a reason for hiding this comment

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

maybe test the runtime class?

Copy link
Member Author

Choose a reason for hiding this comment

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

What do you mean?

Copy link
Member

Choose a reason for hiding this comment

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

well to assert that it is specialised based on the classtag

Copy link
Member Author

Choose a reason for hiding this comment

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

Before this fix, we couldn't even create the array in Line 7, this is a run test witnessing that we are indeed creating the array correctly. Also, dotty will add a call to asInstanceOf[Array[Array[String]]] here which is enough to assert that the right array is created. Also note that asInstanceOf was what indicated that something was really wrong it the generated code.

@hamzaremmal hamzaremmal merged commit e227128 into scala:main Sep 12, 2025
44 checks passed
@hamzaremmal hamzaremmal deleted the i23901 branch September 12, 2025 12:24
WojciechMazur added a commit that referenced this pull request Sep 22, 2025
…mensional `Array`" to 3.7.4 (#24000)

Backports #23902 to the 3.7.4.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added this to the 3.7.4 milestone Sep 23, 2025
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.

Wrong code emitted when creating generic multidimensional arrays
4 participants