Skip to content

Commit bacfeba

Browse files
committed
Fix phantom implicit classes with defined module
1 parent de3a1c8 commit bacfeba

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Desugar.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ object desugar {
482482
else
483483
// implicit wrapper is typechecked in same scope as constructor, so
484484
// we can reuse the constructor parameters; no derived params are needed.
485-
DefDef(className.toTermName, constrTparams, constrVparamss, classTypeRef, creatorExpr)
485+
DefDef(className.toTermName ++ str.NAME_JOIN ++ nme.implicitly, constrTparams, constrVparamss, classTypeRef, creatorExpr)
486486
.withMods(companionMods | Synthetic | Implicit)
487487
.withPos(cdef.pos) :: Nil
488488

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
foo1
2+
foo2
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import scala.reflect.ClassTag
2+
3+
object Test {
4+
import Boo._
5+
6+
def main(args: Array[String]): Unit = {
7+
a.foo1()
8+
a.foo2()
9+
}
10+
11+
implicit class Foo1(x: A) {
12+
def foo1() = println("foo1")
13+
}
14+
15+
object Foo2
16+
implicit class Foo2(x: A) {
17+
def foo2() = println("foo2")
18+
}
19+
}
20+
21+
object Boo extends Phantom {
22+
type A <: this.Any
23+
def a: A = assume
24+
}

0 commit comments

Comments
 (0)