Skip to content

Commit 59bbd4b

Browse files
committed
Remove phantasmic[.]
1 parent 3c52af8 commit 59bbd4b

18 files changed

+55
-201
lines changed

src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -795,10 +795,4 @@ class Definitions {
795795
newCompleteClassSymbol(PhantomPackageClass, tpnme.PhantomNothing, AbstractFinal, List(PhantomAnyType))
796796
def PhantomNothingType = PhantomNothingClass.typeRef
797797

798-
lazy val Phantasmic: TermSymbol = {
799-
def paramBoundsExp(gt: GenericType) = List(TypeBounds(PhantomNothingType, PhantomAnyType))
800-
def resultTypeExp(gt: GenericType) = gt.paramRefs.head
801-
val info = PolyType(List(tpnme.PhantasmicParam))(paramBoundsExp, resultTypeExp)
802-
newMethod(PhantomPackageClass, nme.Phantasmic, info, Flags.Method)
803-
}
804798
}

src/dotty/tools/dotc/core/StdNames.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,6 @@ object StdNames {
305305
val _21 : N = "_21"
306306
val _22 : N = "_22"
307307

308-
val Phantasmic: N = "phantasmic"
309-
val PhantasmicParam: N = "Phantasmic"
310-
311308
val ??? = encode("???")
312309

313310
val genericWrapArray: N = "genericWrapArray"

src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class TreePickler(pickler: TastyPickler) {
258258
case tpe: MethodType if richTypes =>
259259
writeByte(METHODtype)
260260
pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramTypes)
261-
case tpe: PolyType if richTypes || tpe.paramNames.contains("Phantasmic".toTypeName) => // TODO: is this the solution for phantasmic[_]?
261+
case tpe: PolyType if richTypes =>
262262
writeByte(POLYtype)
263263
pickleMethodic(tpe.resultType, tpe.paramNames, tpe.paramBounds)
264264
case tpe: PolyParam =>

src/dotty/tools/dotc/transform/PhantomRefErasure.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ class PhantomRefErasure extends MiniPhaseTransform with InfoTransformer {
3333
assert(!tpe.derivesFrom(defn.PhantomAnyClass), "All phantom type values should be erased in " + tree)
3434

3535
tree match {
36-
case _: TypeTree =>
37-
case _: Trees.TypeDef[_] =>
38-
case _ => assertNotPhantom(tree.tpe)
36+
case _: TypeTree =>
37+
case _: Trees.TypeDef[_] =>
38+
case _ => assertNotPhantom(tree.tpe)
3939
}
4040
super.checkPostCondition(tree)
4141
}

src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ trait TypeAssigner {
201201
if (reallyExists(mbr)) site.select(name, mbr)
202202
else if (site.derivesFrom(defn.DynamicClass) && !Dynamic.isDynamicMethod(name)) {
203203
TryDynamicCallType
204-
} else if (site.derivesFrom(defn.PhantomPackageClass) && name == defn.Phantasmic.name) {
205-
defn.Phantasmic.info
206204
} else {
207205
if (!site.isErroneous) {
208206
ctx.error(

tests/neg/phantomAndOr.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
43

54
class BooFunDef1 {
65
def fun1(b: PhantomAny | Any) = ??? // error

tests/neg/phantomClass.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
43

54
trait Foo
65
trait Boo extends PhantomAny

tests/neg/phantomFunApp.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
3+
4+
class Blinky extends PhantomAny
5+
class Pinky extends Blinky
46

57
class phantomFunApp {
68
def foo(a: Any) = ???
79
def boo(b: PhantomAny) = ???
810

911
foo(1)
10-
foo(phantasmic[PhantomAny]) // error
11-
foo(phantasmic[PhantomNothing]) // error
12+
foo(new Blinky) // error
13+
foo(new Pinky) // error
1214

13-
boo(phantasmic[PhantomAny])
15+
boo(new Blinky)
16+
boo(new Pinky)
1417
boo(1) // error
1518
boo("abc") // error
1619
boo(???) // error

tests/neg/phantomFunDef.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
43

54
class phantomFunDef {
65
def fun1(a: Int, b: PhantomAny) = ??? // error

tests/neg/phantomInstanceOf2.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
43

54
class Blinky extends PhantomAny
65

tests/neg/phantomPhantasmic.scala

Lines changed: 0 additions & 12 deletions
This file was deleted.

tests/neg/phantomStats.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
3+
4+
class Blinky extends PhantomAny
45

56
class phantomStats {
67

7-
phantasmic[PhantomAny] // error
8+
new Blinky // error
89
phantom0 // error
910
phantom1 // error
1011
phantom2() // error
1112

1213
def boo(): Unit = {
13-
phantasmic[PhantomAny] // error
14+
new Blinky // error
1415
phantom0 // error
1516
phantom1 // error
1617
phantom2() // error
1718
()
1819
}
1920

20-
val phantom0: PhantomAny = phantasmic[PhantomAny]
21-
def phantom1: PhantomAny = phantasmic[PhantomAny]
22-
def phantom2(): PhantomAny = phantasmic[PhantomAny]
21+
val phantom0: PhantomAny = new Blinky
22+
def phantom1: PhantomAny = new Blinky
23+
def phantom2(): PhantomAny = new Blinky
2324
}

tests/neg/phantomTypeParamBounds1.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
43

54
class phantomTypeParamBounds1 {
65
def fun5[X >: PhantomNothing <: Any] = ??? // error

tests/neg/phantomTypeParamBounds2.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import dotty.phantom.PhantomAny
22
import dotty.phantom.PhantomNothing
3-
import dotty.phantom.phantasmic
43

54
class phantomTypeParamBounds2 {
65
def fun1[X <: PhantomAny & Any] = ??? // error

tests/neg/phantomVarLazyVal.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import dotty.phantom.PhantomAny
2-
import dotty.phantom.phantasmic
2+
3+
class Blinky extends PhantomAny
34

45
class phantomVarLazyVal {
5-
var a: PhantomAny = phantasmic[PhantomAny] // error
6-
lazy val b: PhantomAny = phantasmic[PhantomAny] // error
6+
var a = new Blinky // error
7+
lazy val b = new Blinky // error
78
}

tests/pos/phantomEq.scala

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import dotty.phantom.phantasmic
21

32
/* This is a example of how to implement Eq using erasable phantom types.
43
*
@@ -21,23 +20,20 @@ object PhantomEq {
2120
(1: Number) === 1.toByte
2221
}
2322

24-
trait PhantomEqUtil {
25-
type PhantomEq[-L, -R] <: dotty.phantom.PhantomAny
26-
type PhantomEqEq[T] = PhantomEq[T, T]
27-
}
28-
2923
object PhantomEqUtil extends PhantomEqUtil {
24+
class PhantomEq[-L, -R] extends dotty.phantom.PhantomAny
25+
type PhantomEqEq[T] = PhantomEq[T, T]
3026

3127
implicit class EqualsDeco[T](val x: T) extends AnyVal {
3228
def ===[U] (y: U)(implicit ce: PhantomEq[T, U]) = x.equals(y)
3329
}
3430

35-
implicit def eqString: PhantomEqEq[String] = phantasmic[PhantomEqEq[String]]
36-
implicit def eqInt: PhantomEqEq[Int] = phantasmic[PhantomEqEq[Int]]
37-
implicit def eqDouble: PhantomEqEq[Double] = phantasmic[PhantomEqEq[Double]]
31+
implicit def eqString: PhantomEqEq[String] = new PhantomEqEq[String]
32+
implicit def eqInt: PhantomEqEq[Int] = new PhantomEqEq[Int]
33+
implicit def eqDouble: PhantomEqEq[Double] = new PhantomEqEq[Double]
3834

39-
implicit def eqByteNum: PhantomEq[Byte, Number] = phantasmic[PhantomEq[Byte, Number]]
40-
implicit def eqNumByte: PhantomEq[Number, Byte] = phantasmic[PhantomEq[Number, Byte]]
35+
implicit def eqByteNum: PhantomEq[Byte, Number] = new PhantomEq[Byte, Number]
36+
implicit def eqNumByte: PhantomEq[Number, Byte] = new PhantomEq[Number, Byte]
4137

42-
implicit def eqSeq[T, U](implicit eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = phantasmic[PhantomEq[Seq[T], Seq[U]]]
38+
implicit def eqSeq[T, U](implicit eq: PhantomEq[T, U]): PhantomEq[Seq[T], Seq[U]] = new PhantomEq[Seq[T], Seq[U]]
4339
}

tests/run/phantom.check

Lines changed: 0 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,12 @@
11
fun1
22
fun1
33
fun1
4-
fun1
5-
fun1
6-
fun1
7-
fun2
8-
fun2
9-
fun2
10-
fun2
114
fun2
125
fun2
136
fun2
147
fun4
158
fun4
169
fun4
17-
fun4
18-
fun4
19-
fun4
20-
fun5
21-
fun5
22-
fun5
2310
fun5
2411
fun5
2512
fun5
@@ -29,33 +16,16 @@ polyfun2
2916
polyfun2
3017
polyfun2
3118
polyfun2
32-
polyfun2
33-
polyfun2
34-
polyfun2
35-
polyfun3
36-
polyfun3
3719
polyfun3
3820
polyfun3
3921
polyfun3
4022
polyfun3
4123
polyfun3
42-
polyfun3
43-
polyfun4
44-
polyfun4
4524
polyfun4
4625
polyfun4
4726
polyfun4
4827
polyfun4
4928
polyfun4
50-
polyfun4
51-
Boo1
52-
Boo1.polyfun1
53-
Boo1
54-
Boo1.polyfun1
55-
Boo1
56-
Boo1.polyfun1
57-
Boo1
58-
Boo1.polyfun1
5929
Boo1
6030
Boo1.polyfun1
6131
Boo1
@@ -66,44 +36,20 @@ Boo2
6636
Boo2.polyfun1
6737
Boo2
6838
Boo2.polyfun1
69-
Boo2
70-
Boo2.polyfun1
71-
Boo2
72-
Boo2.polyfun1
73-
Boo2
74-
Boo2.polyfun1
75-
Boo3
76-
Boo3.polyfun1
7739
Boo3
7840
Boo3.polyfun1
7941
Boo3
8042
Boo3.polyfun1
81-
Boo3
82-
Boo3.polyfun1
83-
Boo3
84-
Boo3.polyfun1
85-
Boo4
86-
Boo4
87-
Boo4
8843
Boo4
8944
Boo4
9045
Boo4
9146
Boo5
9247
Boo5
93-
Boo5
94-
customPhantomsFun1
95-
customPhantomsFun1
9648
customPhantomsFun1
9749
customPhantomsFun1
9850
customPhantomsFun1
9951
customPhantomsFun2
100-
customPhantomsFun2
101-
customPhantomsFun3
102-
customPhantomsFun3
10352
customPhantomsFun3
10453
hkFun1
10554
hkFun1
10655
hkFun1
107-
hkFun1
108-
hkFun1
109-
hkFun1

0 commit comments

Comments
 (0)