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

Ignore private/sealed abstract class/traits #14599

Merged
merged 2 commits into from Mar 2, 2022

Conversation

dwijnand
Copy link
Member

@dwijnand dwijnand commented Mar 1, 2022

Fixes #14579

@dwijnand
Copy link
Member Author

dwijnand commented Mar 1, 2022

lol

def map[F[_]](self: Tuple, f: [t] => t => F[t]): Tuple = self match {
  case EmptyTuple => self
  case _ => fromIArray(self.productIterator.map(f(_).asInstanceOf[Object]).toArray.asInstanceOf[IArray[Object]]) // TODO use toIArray
}
Error:  -- [E030] Match case Unreachable Error: /__w/dotty/dotty/library/src/scala/runtime/Tuples.scala:544:9 
Error:  544 |    case _ => fromIArray(self.productIterator.map(f(_).asInstanceOf[Object]).toArray.asInstanceOf[IArray[Object]]) // TODO use toIArray
Error:      |         ^
Error:      |         Unreachable case
Error:  one error found

Well the logic is right... outside of EmptyTuple, the Tuple class has no subclasses... 🙄 Do I special case tuple-vs-generic-tuple in SpaceEngine too??

@dwijnand dwijnand marked this pull request as ready for review March 2, 2022 08:42
@dwijnand dwijnand requested a review from bishabosha March 2, 2022 08:42
def getChildren(sym: Symbol): List[Symbol] =
sym.children.flatMap { child =>
if child eq sym then Nil // i3145: sealed trait Baz, val x = new Baz {}, Baz.children returns Baz...
else if tp.classSymbol == defn.TupleClass || tp.classSymbol == defn.NonEmptyTupleClass then List(child) // Tuple is weird/different...
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
else if tp.classSymbol == defn.TupleClass || tp.classSymbol == defn.NonEmptyTupleClass then List(child) // Tuple is weird/different...
else if tp.classSymbol == defn.TupleClass || tp.classSymbol == defn.NonEmptyTupleClass then List(child) // Tuple types are substituted for different classes at runtime

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, it makes me think: is there a reason TupleXXL doesn't extend Tuple and the TupleN classes made synthetically to extend Tuple? Then we wouldn't need this.

@dwijnand dwijnand enabled auto-merge March 2, 2022 14:54
@dwijnand dwijnand merged commit 859214a into scala:main Mar 2, 2022
@dwijnand dwijnand deleted the patmat-private-sealed branch March 4, 2022 20:36
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
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.

forward port knowledge of private and sealed traits in exhaustivity warnings
3 participants