Skip to content

Remove erroneous usages of List::union #5585

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

Merged
merged 1 commit into from
Dec 10, 2018
Merged
Show file tree
Hide file tree
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/core/Decorators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ object Decorators {
}

/** Union on lists seen as sets */
def | (ys: List[T]): List[T] = xs ++ (ys filterNot (xs contains _))
def | (ys: List[T]): List[T] = xs ::: (ys filterNot (xs contains _))
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we should do xs filterNot (ys contains _) ::: ys to always share the tail.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe. I did't want to change the semantic. Maybe ordering matters.

I suggest trying out optimisations in another PR. Definitely worth investigating!

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed


/** Intersection on lists seen as sets */
def & (ys: List[T]): List[T] = xs filter (ys contains _)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class OrderingConstraint(private val boundsMap: ParamBounds,
def dependentParams(tp: Type, isUpper: Boolean): List[TypeParamRef] = tp match {
case param: TypeParamRef if contains(param) =>
param :: (if (isUpper) upper(param) else lower(param))
case tp: AndType => dependentParams(tp.tp1, isUpper).union (dependentParams(tp.tp2, isUpper))
case tp: AndType => dependentParams(tp.tp1, isUpper) | (dependentParams(tp.tp2, isUpper))
case tp: OrType => dependentParams(tp.tp1, isUpper).intersect(dependentParams(tp.tp2, isUpper))
case _ =>
Nil
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ object Types {
case tp: TypeProxy =>
tp.underlying.classSymbols
case AndType(l, r) =>
l.classSymbols union r.classSymbols
l.classSymbols | r.classSymbols
case OrType(l, r) =>
l.classSymbols intersect r.classSymbols // TODO does not conform to spec
case _ =>
Expand Down