File tree 1 file changed +50
-2
lines changed 1 file changed +50
-2
lines changed Original file line number Diff line number Diff line change
1
+ import LightTypeTagInheritance ._
2
+
3
+ trait LightTypeTagRef
4
+
5
+ object LightTypeTagInheritance {
6
+ private final case class Ctx (self : LightTypeTagInheritance ) {
7
+ def next (): Ctx = Ctx (self)
8
+ }
9
+ private implicit final class CtxExt (private val ctx : Ctx ) extends AnyVal {
10
+ def isChild (selfT0 : LightTypeTagRef , thatT0 : LightTypeTagRef ): Boolean = ctx.self.isChild(ctx.next())(selfT0, thatT0)
11
+ }
12
+ }
13
+
14
+ class LightTypeTagInheritance {
15
+
16
+ def isChild (s : LightTypeTagRef , t : LightTypeTagRef ): Boolean = {
17
+ isChild(new Ctx (this ))(s, t)
18
+ }
19
+
20
+ private def isChild (ctx : Ctx )(s : LightTypeTagRef , t : LightTypeTagRef ): Boolean = {
21
+ ctx.isChild(s, t)
22
+ }
23
+
24
+ }
25
+
26
+ object App extends App {
27
+ println(LightTypeTagInheritance )
28
+ }
29
+
30
+
1
31
object Foo {
2
32
case class Bar (i : Int )
3
33
@@ -10,6 +40,24 @@ class Foo {
10
40
def bar = Foo .Bar (1 ).twice
11
41
}
12
42
13
- object App extends App {
43
+ object App2 extends App {
14
44
println((new Foo ).bar)
15
- }
45
+ }
46
+
47
+ object Foo2 {
48
+ case class Bar (i : Int )
49
+
50
+ private given BarOps : AnyRef with {
51
+ extension (bar : Bar )
52
+ def twice : Bar = Bar (bar.i * 2 )
53
+ }
54
+ }
55
+
56
+ class Foo2 {
57
+ def bar = Foo2 .Bar (1 ).twice
58
+ }
59
+
60
+ object App3 extends App {
61
+ println((new Foo2 ).bar)
62
+ }
63
+
You can’t perform that action at this time.
0 commit comments