Skip to content

Commit 2451c93

Browse files
committed
WIP
1 parent a503b7a commit 2451c93

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,13 @@ object NameKinds {
343343
}
344344
}
345345

346+
/** Names of the form underlying$mapped$N. Used by overloading resolution for
347+
* mapped alternatives that have their parameters skipped.
348+
*/
349+
val MappedAltName: NumberedNameKind = new NumberedNameKind(SHIFTED_ALT, "MappedAlt"):
350+
def mkString(underlying: TermName, info: ThisInfo) =
351+
s"$underlying${str.SHIFTED}${info.num}"
352+
346353
/** Names of the form N_<outer>. Emitted by inliner, replaced by outer path
347354
* in ExplicitOuter.
348355
*/

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ object NameTags extends TastyFormat.NameTags {
1313
// outer accessor that will be filled in by ExplicitOuter.
1414
// <num> indicates the number of hops needed to select the outer field.
1515

16+
inline val SHIFTED_ALT = 14 // A name `alt$shifted$n` for a mapped symbol in an overloading
17+
// resolution where `n` term parameters have been stripped
18+
1619
inline val PROTECTEDACCESSOR = 24 // The name of a protected accesor `protected$<name>` created by ProtectedAccessors.
1720

1821
inline val INITIALIZER = 26 // A mixin initializer method

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ object StdNames {
2222
inline val TOPLEVEL_SUFFIX = "$package"
2323
inline val NAME_JOIN = "$"
2424
inline val DEFAULT_GETTER = "$default$"
25+
inline val SHIFTED = "$shifted$"
2526
inline val LOCALDUMMY_PREFIX = "<local " // owner of local blocks
2627
inline val ANON_CLASS = "$anon"
2728
inline val ANON_FUN = "$anonfun"

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Trees._
1818
import Names._
1919
import StdNames._
2020
import ContextOps._
21-
import NameKinds.DefaultGetterName
21+
import NameKinds.{DefaultGetterName, MappedAltName}
2222
import ProtoTypes._
2323
import Inferencing._
2424
import reporting._
@@ -229,16 +229,19 @@ object Applications {
229229
EmptyTree
230230
}
231231
}
232+
val (methName, skipped) = meth.name match
233+
case MappedAltName(mname, n) => (mname, n)
234+
case mname => (mname, 0)
232235
val getterPrefix =
233-
if (meth.is(Synthetic) && meth.name == nme.apply) nme.CONSTRUCTOR else meth.name
234-
def getterName = DefaultGetterName(getterPrefix, n + numArgs(fn))
236+
if (meth.is(Synthetic) && methName == nme.apply) nme.CONSTRUCTOR else methName
237+
def getterName = DefaultGetterName(getterPrefix, n + numArgs(fn) + skipped)
235238
if !meth.hasDefaultParams then
236239
EmptyTree
237240
else if (receiver.isEmpty) {
238241
def findGetter(cx: Context): Tree =
239242
if (cx eq NoContext) EmptyTree
240243
else if (cx.scope != cx.outer.scope &&
241-
cx.denotNamed(meth.name).hasAltWith(_.symbol == meth)) {
244+
cx.denotNamed(methName).hasAltWith(_.symbol == meth)) {
242245
val denot = cx.denotNamed(getterName)
243246
if (denot.exists) ref(TermRef(cx.owner.thisType, getterName, denot))
244247
else findGetter(cx.outer)

0 commit comments

Comments
 (0)