Skip to content

Commit 83734e1

Browse files
committed
Generalize symbolic refs
Previously, there was a switch in SymDenotation#termRef to create a WithFixedSym ref when after erasure. This was done to fix a broken test, but it's clearly incomplete. The scheme is now replaced by one which always creates WithFixedSym Termrefs after erasure.
1 parent f2e3489 commit 83734e1

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,8 @@ object SymDenotations {
896896
override def valRef(implicit ctx: Context): TermRef =
897897
TermRef.withSigAndDenot(owner.thisType, name.asTermName, Signature.NotAMethod, this)
898898

899-
override def termRefWithSig(implicit ctx: Context): TermRef = // TODO generalize
900-
if (ctx.erasedTypes) TermRef.withFixedSym(owner.thisType, name.asTermName, symbol.asTerm)
901-
else TermRef.withSigAndDenot(owner.thisType, name.asTermName, signature, this)
899+
override def termRefWithSig(implicit ctx: Context): TermRef =
900+
TermRef.withSigAndDenot(owner.thisType, name.asTermName, signature, this)
902901

903902
def nonMemberTermRef(implicit ctx: Context): TermRef =
904903
TermRef.withFixedSym(owner.thisType, name.asTermName, symbol.asTerm)

src/dotty/tools/dotc/core/Types.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,7 +1183,7 @@ object Types {
11831183
// That's why the branch is disabled.
11841184
//
11851185
// else if (ctx.erasedTypes && lastSymbol != null)
1186-
// denotOfSym(lastSymbol)
1186+
// denotOfSym(lastSymbol)
11871187
else
11881188
d.current
11891189
}
@@ -1516,7 +1516,7 @@ object Types {
15161516
* signature, if denotation is not yet completed.
15171517
*/
15181518
def apply(prefix: Type, name: TermName, denot: Denotation)(implicit ctx: Context): TermRef = {
1519-
if ((prefix eq NoPrefix) || denot.symbol.isFresh)
1519+
if ((prefix eq NoPrefix) || denot.symbol.isFresh || ctx.erasedTypes)
15201520
apply(prefix, denot.symbol.asTerm)
15211521
else denot match {
15221522
case denot: SymDenotation if denot.isCompleted => withSig(prefix, name, denot.signature)
@@ -1538,7 +1538,7 @@ object Types {
15381538
* (2) The name in the term ref need not be the same as the name of the Symbol.
15391539
*/
15401540
def withSymAndName(prefix: Type, sym: TermSymbol, name: TermName)(implicit ctx: Context): TermRef =
1541-
if ((prefix eq NoPrefix) || sym.isFresh)
1541+
if ((prefix eq NoPrefix) || sym.isFresh || ctx.erasedTypes)
15421542
withFixedSym(prefix, name, sym)
15431543
else if (sym.defRunId != NoRunId && sym.isCompleted)
15441544
withSig(prefix, name, sym.signature) withSym (sym, sym.signature)
@@ -1549,7 +1549,7 @@ object Types {
15491549
* (which must be completed).
15501550
*/
15511551
def withSig(prefix: Type, sym: TermSymbol)(implicit ctx: Context): TermRef =
1552-
if ((prefix eq NoPrefix) || sym.isFresh) withFixedSym(prefix, sym.name, sym)
1552+
if ((prefix eq NoPrefix) || sym.isFresh || ctx.erasedTypes) withFixedSym(prefix, sym.name, sym)
15531553
else withSig(prefix, sym.name, sym.signature).withSym(sym, sym.signature)
15541554

15551555
/** Create a term ref with given prefix, name and signature */
@@ -1558,7 +1558,7 @@ object Types {
15581558

15591559
/** Create a term ref with given prefix, name, signature, and initial denotation */
15601560
def withSigAndDenot(prefix: Type, name: TermName, sig: Signature, denot: Denotation)(implicit ctx: Context): TermRef = {
1561-
if ((prefix eq NoPrefix) || denot.symbol.isFresh)
1561+
if ((prefix eq NoPrefix) || denot.symbol.isFresh || ctx.erasedTypes)
15621562
withFixedSym(prefix, denot.symbol.asTerm.name, denot.symbol.asTerm)
15631563
else
15641564
withSig(prefix, name, sig)

0 commit comments

Comments
 (0)