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

Fix some more collection errors #1431

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

olabusayoT
Copy link
Contributor

  • fix implicit Array to Seq error using ArraySeq.unsafeWrapArray
  • fix inheritance shadowing error by renaming function and using this._
  • fix deprecated Array to Scala varargs
  • add MultiMapWrapper class since MultiMaps and extending HashMaps are deprecated
  • replace deprecated Map.filterKeys with Map.filter( case(k,v) => k...)
  • replace deprecated Map.mapValues with suggested Map.values.map
  • remove deprecated Either.right since it's the default view now

DAFFODIL-2152

- fix implicit Array to Seq error using ArraySeq.unsafeWrapArray
- fix inheritance shadowing error by renaming function and using this._
- fix deprecated Array to Scala varargs
- add MultiMapWrapper class since MultiMaps and extending HashMaps are deprecated
- replace deprecated Map.filterKeys with Map.filter( case(k,v) => k...)
- replace deprecated Map.mapValues with suggested Map.values.map
- remove deprecated Either.right since it's the default view now

DAFFODIL-2152
Copy link
Contributor

@mbeckerle mbeckerle left a comment

Choose a reason for hiding this comment

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

+1 just a few questions/observations.

"-Xlint:nullary-unit"
"-Xlint:nullary-unit",
// the import is needed for Scala 2.12 but issues an unused import warning under 2.13, so we add this to
// suppresss the warning
Copy link
Contributor

Choose a reason for hiding this comment

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

Whenever we do this sort of scala 2.12 compatibility thing, I think we should anticipate that we will drop scala 2.12 fairly quickly once we've moved to scala 2.13 or scala 3. So I would add a // TODO: scala 2.12 phase out or other easily identified TODO item.

* Compatibility class for 2.12 and 2.13 since MultiMap and inheritance
* from class mutable.HashMap have been deprecated in 2.13.
*/
class MultiMapWrapper[K, V] {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes this is a wrapper, but I think this should just be called MultiMap.

def removeBinding(key: K, value: V): Unit =
underlying.get(key).foreach { values =>
values -= value
if (values.isEmpty) underlying -= key
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm going to suggest we just ignore these codecov as part of this scala 2.13/scala 3 conversion process.

We can always run a complete code-cov analysis later.

@@ -953,7 +954,7 @@ abstract class TestCase(testCaseXML: NodeSeq, val parent: DFDLTestSuite) {
tunables
)

val newCompileResult: TDML.CompileResult = compileResult.right.map {
val newCompileResult: TDML.CompileResult = compileResult.map {
Copy link
Contributor

Choose a reason for hiding this comment

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

So compileResult isnt an Either[L,R] type anymore? That's a pretty major change and seems unmotivated for this port to new scala version.

Can you explain why this was needed?

Copy link
Contributor Author

@olabusayoT olabusayoT Feb 12, 2025

Choose a reason for hiding this comment

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

compileResult is still an Either[L,R], but .right is deprecated since it is now the default representation. .left still works though

"Either is right-biased, which means that Right is assumed to be the default case to operate on. "
https://www.scala-lang.org/api/2.13.16/scala/util/Either.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I add a comment in the code?

- MultiMapWrapper -> MultiMap
- add comments for 2.12 phase out

DAFFODIL-2152
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