File tree 2 files changed +21
-9
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -503,15 +503,16 @@ class Typer extends Namer
503
503
// Convert a reference `f` to an extension method select `p.f`, where
504
504
// `p` is the closest enclosing extension parameter, or else convert to `this.f`.
505
505
val xmethod = ctx.owner.enclosingExtensionMethod
506
- val qualifier =
507
- if xmethod.exists then untpd.ref(xmethod.extensionParam.termRef)
508
- else untpd.This (untpd.EmptyTypeIdent )
509
- val selection = untpd.cpy.Select (tree)(qualifier, name)
510
- val result = tryEither(typed(selection, pt))((_, _) => fail)
511
- def canAccessUnqualified (sym : Symbol ) =
512
- sym.is(ExtensionMethod ) && (sym.extensionParam.span == xmethod.extensionParam.span)
513
- if ! xmethod.exists || result.tpe.isError || canAccessUnqualified(result.symbol) then
514
- result
506
+ if xmethod.exists then
507
+ val qualifier = untpd.ref(xmethod.extensionParam.termRef)
508
+ val selection = untpd.cpy.Select (tree)(qualifier, name)
509
+ val result = tryEither(typed(selection, pt))((_, _) => fail)
510
+ def canAccessUnqualified (sym : Symbol ) =
511
+ sym.is(ExtensionMethod ) && (sym.extensionParam.span == xmethod.extensionParam.span)
512
+ if result.tpe.isError || canAccessUnqualified(result.symbol) then
513
+ result
514
+ else
515
+ fail
515
516
else
516
517
fail
517
518
else
Original file line number Diff line number Diff line change
1
+ class MyInt (val x : Int ) {
2
+ def eq (that : MyInt ): Boolean = this .x == that.x
3
+ }
4
+
5
+ class Test {
6
+ def foo (x : MyInt , y : MyInt ): Boolean = x.eq(y)
7
+
8
+ val a = MyInt (2 )
9
+ val b = MyInt (3 )
10
+ foo(a, b)
11
+ }
You can’t perform that action at this time.
0 commit comments