Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Better types for class type parameters
If we see a class type parameter that has a wildcard argument, we now intersect the original info of the class type parameter and the argument. Previously we replaced the class type parameter info with the argument info, but that might lose information. Fixes #15940
  • Loading branch information
odersky committed Sep 2, 2022
commit 57f53d0725c859bffcadc8919524b9b0d43805ba
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ object Denotations {
then this
else if symbol.isAllOf(ClassTypeParam) then
val arg = symbol.typeRef.argForParam(pre, widenAbstract = true)
if arg.exists then derivedSingleDenotation(symbol, arg.bounds, pre)
if arg.exists then derivedSingleDenotation(symbol, symbol.info.bounds & arg.bounds, pre)
else derived(symbol.info)
else derived(symbol.info)
}
Expand Down
19 changes: 19 additions & 0 deletions tests/pos/i15940.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
object Ops:
implicit class EitherSeqOps[E, T](private val seq: Seq[Either[E, T]]) extends AnyVal:
def sequence: Either[::[E], Seq[T]] = ???

trait BuildException
case class CompositeBuildException(ex: ::[BuildException]) extends BuildException

trait ActionableDiagnostic
trait ActionableHandler[A <: ActionableDiagnostic]:
def exec: Either[BuildException, Seq[A]]

import Ops._

val test: Either[BuildException, Seq[ActionableDiagnostic]] =
// Can be replaced with Seq[Either[BuildException, Seq[ _ <: ActionableDiagnostic]]] , but current version matches better type of missing implicit
Seq.empty[ActionableHandler[_]].map(_.exec)
.sequence
.left.map(_.head)
.map(_.flatten) // error