File tree Expand file tree Collapse file tree 2 files changed +18
-9
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -452,16 +452,14 @@ 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
455
460
val qualifier =
456
- if xmethod.exists then // TODO: see whether we can use paramss for that
457
- val leadParamName = xmethod.info.paramNamess.head.head
458
- def isLeadParam (sym : Symbol ) =
459
- sym.is(Param ) && sym.owner.owner == xmethod.owner && sym.name == leadParamName
460
- def leadParam (ctx : Context ): Symbol =
461
- ctx.scope.lookupAll(leadParamName).find(isLeadParam) match
462
- case Some (param) => param
463
- case None => leadParam(ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next)
464
- untpd.ref(leadParam(ctx).termRef)
461
+ if xmethod.exists then
462
+ untpd.ref(leadingParam(xmethod.rawParamss).termRef)
465
463
else
466
464
untpd.This (untpd.EmptyTypeIdent )
467
465
untpd.cpy.Select (tree)(qualifier, name)
Original file line number Diff line number Diff line change
1
+ class Foo :
2
+ def foo = 23
3
+
4
+ object Unrelated :
5
+ extension (f : Foo )
6
+ def g = f.foo // OK
7
+
8
+ extension (f : Foo )
9
+ def h1 : Int = 0
10
+ def h2 : Int = h1 + 1 // OK
11
+ def ++: (x : Int ): Int = h2 + x // OK
You can’t perform that action at this time.
0 commit comments