File tree 2 files changed +22
-4
lines changed
compiler/src/dotty/tools/dotc/typer
2 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -3994,10 +3994,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
3994
3994
gadts.println(i " Trying to heal member selection by GADT-approximating $wtp" )
3995
3995
val gadtApprox = Inferencing .approximateGADT(wtp)
3996
3996
gadts.println(i " GADT-approximated $wtp ~~ $gadtApprox" )
3997
- if pt.isMatchedBy(gadtApprox) then
3998
- gadts.println(i " Member selection healed by GADT approximation " )
3999
- tree.cast(gadtApprox)
4000
- else tree
3997
+ gadts.println(i " Member selection healed by GADT approximation " )
3998
+ tree.cast(gadtApprox)
4001
3999
else if tree.tpe.derivesFrom(defn.PairClass ) && ! defn.isTupleNType(tree.tpe.widenDealias) then
4002
4000
// If this is a generic tuple we need to cast it to make the TupleN/ members accessible.
4003
4001
// This works only for generic tuples of known size up to 22.
Original file line number Diff line number Diff line change
1
+ trait MyData
2
+
3
+ object MyData :
4
+ extension (m : MyData )
5
+ def printIt () = println(" hey from my data" )
6
+
7
+ class MyClass :
8
+ def sel (s : String ): Int = s.hashCode()
9
+
10
+ enum MyTag [A ]:
11
+ case MyDataTag extends MyTag [MyData ]
12
+ case MyClassTag extends MyTag [MyClass ]
13
+
14
+ def callExtension [A ](tag : MyTag [A ], a: A ): Unit =
15
+ tag match
16
+ case MyTag .MyDataTag => a.printIt()
17
+ case MyTag .MyClassTag => a.sel(" hi" )
18
+
19
+ def callExtensionDirectly (m : MyData ): Unit =
20
+ m.printIt()
You can’t perform that action at this time.
0 commit comments