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 {
7272 def isAnonymousClassName : Boolean = name.startsWith(str.ANON_CLASS )
7373 def isAnonymousFunctionName : Boolean = name.startsWith(str.ANON_FUN )
7474 def isUnapplyName : Boolean = name == nme.unapply || name == nme.unapplySeq
75+ def isRightAssocOperatorName : Boolean = name.lastPart.last == ':'
7576
7677 def isOperatorName : Boolean = name match
7778 case name : SimpleName => name.exists(isOperatorPart)
Original file line number Diff line number Diff line change @@ -325,6 +325,18 @@ object SymDenotations {
325325 else recurWithParamss(info, rawParamss)
326326 end paramSymss
327327
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+
328340 /** The denotation is completed: info is not a lazy type and attributes have defined values */
329341 final def isCompleted : Boolean = ! myInfo.isInstanceOf [LazyType ]
330342
Original file line number Diff line number Diff line change @@ -452,16 +452,9 @@ class Typer extends Namer
452452 */
453453 def extensionMethodSelect : untpd.Tree =
454454 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
460455 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 )
465458 untpd.cpy.Select (tree)(qualifier, name)
466459
467460 val rawType = {
You can’t perform that action at this time.
0 commit comments