File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed
compiler/src/dotty/tools/dotc Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change @@ -72,6 +72,7 @@ object NameOps {
72
72
def isAnonymousClassName : Boolean = name.startsWith(str.ANON_CLASS )
73
73
def isAnonymousFunctionName : Boolean = name.startsWith(str.ANON_FUN )
74
74
def isUnapplyName : Boolean = name == nme.unapply || name == nme.unapplySeq
75
+ def isRightAssocOperatorName : Boolean = name.lastPart.last == ':'
75
76
76
77
def isOperatorName : Boolean = name match
77
78
case name : SimpleName => name.exists(isOperatorPart)
Original file line number Diff line number Diff line change @@ -325,6 +325,18 @@ object SymDenotations {
325
325
else recurWithParamss(info, rawParamss)
326
326
end paramSymss
327
327
328
+ /** The extension parameter of this extension method
329
+ * @pre this symbol is an extension method
330
+ */
331
+ final def extensionParam (using Context ): Symbol =
332
+ def leadParam (paramss : List [List [Symbol ]]): Symbol = paramss match
333
+ case (param :: _) :: paramss1 if param.isType => leadParam(paramss1)
334
+ case _ :: (snd :: Nil ) :: _ if name.isRightAssocOperatorName => snd
335
+ case (fst :: Nil ) :: _ => fst
336
+ case _ => NoSymbol
337
+ assert(isAllOf(ExtensionMethod ))
338
+ leadParam(rawParamss)
339
+
328
340
/** The denotation is completed: info is not a lazy type and attributes have defined values */
329
341
final def isCompleted : Boolean = ! myInfo.isInstanceOf [LazyType ]
330
342
Original file line number Diff line number Diff line change @@ -452,16 +452,9 @@ class Typer extends Namer
452
452
*/
453
453
def extensionMethodSelect : untpd.Tree =
454
454
val xmethod = ctx.owner.enclosingExtensionMethod
455
- def leadingParam (paramss : List [List [Symbol ]]): Symbol = paramss match
456
- case (param :: _) :: paramss1 if param.isType => leadingParam(paramss1)
457
- case _ :: (snd :: Nil ) :: _ if ! isLeftAssoc(xmethod.name) => snd
458
- case (fst :: Nil ) :: _ => fst
459
- case _ => NoSymbol
460
455
val qualifier =
461
- if xmethod.exists then
462
- untpd.ref(leadingParam(xmethod.rawParamss).termRef)
463
- else
464
- untpd.This (untpd.EmptyTypeIdent )
456
+ if xmethod.exists then untpd.ref(xmethod.extensionParam.termRef)
457
+ else untpd.This (untpd.EmptyTypeIdent )
465
458
untpd.cpy.Select (tree)(qualifier, name)
466
459
467
460
val rawType = {
You can’t perform that action at this time.
0 commit comments