Skip to content

Generalize isArgPrefixOf #11063

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
Jan 12, 2021
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
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,_] => ???
}
}