Skip to content

Commit 04c51b3

Browse files
committed
Erase arguments of phantom type
This commit removes arguments and parameter of phantom type from all applications. Arguments are evaluated before the application in case they have side effects. ``` def foo(i: Int, p: SomePhantom) = ??? foo(42, { println("hello"); getSomePhantom }) ``` becomes ``` def foo(i: Int) = ??? val x$0 = 42 val x$1 = { println("hello"); getSomePhantom } foo(x$0) ``` Note that now `def foo(i: Int)` and def `foo(i: Int, p: SomePhantom)` erase to the same signature. Tests for this commit where added in `Extra tests for Phantoms 1`, they where back ported as the semantics and runtime is not affected.
1 parent 1d0e940 commit 04c51b3

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/run/Fooooo.scala

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import scala.reflect.ClassTag
2+
3+
object Test {
4+
5+
def main(args: Array[String]): Unit = {
6+
bar1(Foo.a)
7+
bar2(Foo.a)(null)
8+
}
9+
10+
def bar1(ev: Foo.A) = ()
11+
def bar2(ev: Foo.A)(implicit c: ClassTag[Int]) = implicitly[ClassTag[Int]]
12+
}
13+
14+
object Foo extends Phantom {
15+
type A <: this.Any
16+
def a: A = assume
17+
}

0 commit comments

Comments
 (0)