Skip to content

Commit

Permalink
Merge pull request scala#11063 from dotty-staging/fix-#11057
Browse files Browse the repository at this point in the history
Generalize isArgPrefixOf
  • Loading branch information
liufengyun committed Jan 12, 2021
2 parents 25b0743 + 91c18e7 commit 5950f83
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
8 changes: 5 additions & 3 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -289,14 +289,15 @@ object Types {
def isFromJavaObject(using Context): Boolean = typeSymbol eq defn.FromJavaObjectSymbol

/** True iff `symd` is a denotation of a class type parameter and the reference
* `<this> . <symd>` is an actual argument reference, i.e. `this` is different
* from the ThisType of `symd`'s owner.
* `<pre> . <symd>` is an actual argument reference, i.e. `pre` is not the
* ThisType of `symd`'s owner, or a reference to `symd`'s owner.'
*/
def isArgPrefixOf(symd: SymDenotation)(using Context): Boolean =
symd.exists && !symd.owner.is(Package) && // Early exit if possible because the next check would force SymbolLoaders
symd.isAllOf(ClassTypeParam) && {
this match {
case tp: ThisType => tp.cls ne symd.owner
case tp: TypeRef => tp.symbol ne symd.owner
case _ => true
}
}
Expand Down Expand Up @@ -2212,7 +2213,8 @@ object Types {
throw new TypeError(
i"""bad parameter reference $this at ${ctx.phase}
|the parameter is ${param.showLocated} but the prefix $prefix
|does not define any corresponding arguments.""")
|does not define any corresponding arguments.
|idx = $idx, args = $args""")
NoDenotation
}
}
Expand Down
20 changes: 20 additions & 0 deletions tests/pos/i11057.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
object data {

trait OfType[T]
case object IntT extends OfType[Int]
case object DoubleT extends OfType[Double]
case object FloatT extends OfType[Float]

type DSeq[X] = scala.collection.immutable.AbstractSeq[X]

case class ColumnName[T](n:String, t: OfType[T])
case class Column[T,F[_]<:DSeq[_]](n:F[T], of: ColumnName[T])
}

def min4[T,F[_]<:data.DSeq[T]](col: data.Column[T,F])(using Ordering[T]): T = {
col match {
case c:data.Column[Int,_] => c.n.min[T](Ordering[T])
case _:data.Column[Double,_] => ???
case _:data.Column[Float,_] => ???
}
}

0 comments on commit 5950f83

Please sign in to comment.