Skip to content

An alternative fix to #5808 #5851

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
Feb 6, 2019
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
9 changes: 4 additions & 5 deletions compiler/src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
case _ => 0
}
var allAlts = denot.alternatives
.map(_.termRef).filter(tr => typeParamCount(tr) == targs.length)
.map(denot => TermRef(receiver.tpe, denot.symbol))
.filter(tr => typeParamCount(tr) == targs.length)
if (targs.isEmpty) allAlts = allAlts.filterNot(_.widen.isInstanceOf[PolyType])
val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
assert(alternatives.size == 1,
Expand All @@ -1084,10 +1085,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it
alternatives.head
}
else denot.asSingleDenotation.termRef
val fun = receiver
.select(TermRef(receiver.tpe, selected.termSymbol.asTerm))
.appliedToTypes(targs)
else TermRef(receiver.tpe, denot.symbol)
val fun = receiver.select(selected).appliedToTypes(targs)

val apply = untpd.Apply(fun, args)
new typer.ApplyToTyped(apply, fun, selected, args, expectedType).result.asInstanceOf[Tree] // needed to handle varargs
Expand Down
20 changes: 0 additions & 20 deletions compiler/src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -748,26 +748,6 @@ object Denotations {
if (matches) this else NoDenotation
}

// ------ Forming types -------------------------------------------

/** The TypeRef representing this type denotation at its original location. */
def typeRef(implicit ctx: Context): TypeRef =
TypeRef(symbol.owner.thisType, symbol).withDenot(this)

/** The typeRef applied to its own type parameters */
def appliedRef(implicit ctx: Context): Type =
typeRef.appliedTo(symbol.typeParams.map(_.typeRef))

/** The TermRef representing this term denotation at its original location. */
def termRef(implicit ctx: Context): TermRef =
TermRef(symbol.owner.thisType, symbol).withDenot(this)

/** The NamedType representing this denotation at its original location.
* Same as either `typeRef` or `termRef` depending whether this denotes a type or not.
*/
def namedType(implicit ctx: Context): NamedType =
if (isType) typeRef else termRef

// ------ Transformations -----------------------------------------

private[this] var myValidFor: Period = Nowhere
Expand Down
14 changes: 12 additions & 2 deletions compiler/src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1233,12 +1233,22 @@ object SymDenotations {
/** The type This(cls), where cls is this class, NoPrefix for all other symbols */
def thisType(implicit ctx: Context): Type = NoPrefix

override def typeRef(implicit ctx: Context): TypeRef =
def typeRef(implicit ctx: Context): TypeRef =
TypeRef(owner.thisType, symbol)

override def termRef(implicit ctx: Context): TermRef =
def termRef(implicit ctx: Context): TermRef =
TermRef(owner.thisType, symbol)

/** The typeRef applied to its own type parameters */
def appliedRef(implicit ctx: Context): Type =
typeRef.appliedTo(symbol.typeParams.map(_.typeRef))

/** The NamedType representing this denotation at its original location.
* Same as either `typeRef` or `termRef` depending whether this denotes a type or not.
*/
def namedType(implicit ctx: Context): NamedType =
if (isType) typeRef else termRef

/** The variance of this type parameter or type member as an Int, with
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
*/
Expand Down