Skip to content

Commit 788b4fa

Browse files
authored
Merge pull request #5851 from dotty-staging/fix-5808
An alternative fix to #5808
2 parents 2a973bc + 24e9f52 commit 788b4fa

File tree

3 files changed

+16
-27
lines changed

3 files changed

+16
-27
lines changed

compiler/src/dotty/tools/dotc/ast/tpd.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10741074
case _ => 0
10751075
}
10761076
var allAlts = denot.alternatives
1077-
.map(_.termRef).filter(tr => typeParamCount(tr) == targs.length)
1077+
.map(denot => TermRef(receiver.tpe, denot.symbol))
1078+
.filter(tr => typeParamCount(tr) == targs.length)
10781079
if (targs.isEmpty) allAlts = allAlts.filterNot(_.widen.isInstanceOf[PolyType])
10791080
val alternatives = ctx.typer.resolveOverloaded(allAlts, proto)
10801081
assert(alternatives.size == 1,
@@ -1084,10 +1085,8 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
10841085
i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it
10851086
alternatives.head
10861087
}
1087-
else denot.asSingleDenotation.termRef
1088-
val fun = receiver
1089-
.select(TermRef(receiver.tpe, selected.termSymbol.asTerm))
1090-
.appliedToTypes(targs)
1088+
else TermRef(receiver.tpe, denot.symbol)
1089+
val fun = receiver.select(selected).appliedToTypes(targs)
10911090

10921091
val apply = untpd.Apply(fun, args)
10931092
new typer.ApplyToTyped(apply, fun, selected, args, expectedType).result.asInstanceOf[Tree] // needed to handle varargs

compiler/src/dotty/tools/dotc/core/Denotations.scala

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -748,26 +748,6 @@ object Denotations {
748748
if (matches) this else NoDenotation
749749
}
750750

751-
// ------ Forming types -------------------------------------------
752-
753-
/** The TypeRef representing this type denotation at its original location. */
754-
def typeRef(implicit ctx: Context): TypeRef =
755-
TypeRef(symbol.owner.thisType, symbol).withDenot(this)
756-
757-
/** The typeRef applied to its own type parameters */
758-
def appliedRef(implicit ctx: Context): Type =
759-
typeRef.appliedTo(symbol.typeParams.map(_.typeRef))
760-
761-
/** The TermRef representing this term denotation at its original location. */
762-
def termRef(implicit ctx: Context): TermRef =
763-
TermRef(symbol.owner.thisType, symbol).withDenot(this)
764-
765-
/** The NamedType representing this denotation at its original location.
766-
* Same as either `typeRef` or `termRef` depending whether this denotes a type or not.
767-
*/
768-
def namedType(implicit ctx: Context): NamedType =
769-
if (isType) typeRef else termRef
770-
771751
// ------ Transformations -----------------------------------------
772752

773753
private[this] var myValidFor: Period = Nowhere

compiler/src/dotty/tools/dotc/core/SymDenotations.scala

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,12 +1233,22 @@ object SymDenotations {
12331233
/** The type This(cls), where cls is this class, NoPrefix for all other symbols */
12341234
def thisType(implicit ctx: Context): Type = NoPrefix
12351235

1236-
override def typeRef(implicit ctx: Context): TypeRef =
1236+
def typeRef(implicit ctx: Context): TypeRef =
12371237
TypeRef(owner.thisType, symbol)
12381238

1239-
override def termRef(implicit ctx: Context): TermRef =
1239+
def termRef(implicit ctx: Context): TermRef =
12401240
TermRef(owner.thisType, symbol)
12411241

1242+
/** The typeRef applied to its own type parameters */
1243+
def appliedRef(implicit ctx: Context): Type =
1244+
typeRef.appliedTo(symbol.typeParams.map(_.typeRef))
1245+
1246+
/** The NamedType representing this denotation at its original location.
1247+
* Same as either `typeRef` or `termRef` depending whether this denotes a type or not.
1248+
*/
1249+
def namedType(implicit ctx: Context): NamedType =
1250+
if (isType) typeRef else termRef
1251+
12421252
/** The variance of this type parameter or type member as an Int, with
12431253
* +1 = Covariant, -1 = Contravariant, 0 = Nonvariant, or not a type parameter
12441254
*/

0 commit comments

Comments
 (0)