diff options
author | Guillaume Martres <smarter@ubuntu.com> | 2015-07-04 18:10:59 +0200 |
---|---|---|
committer | Guillaume Martres <smarter@ubuntu.com> | 2015-07-07 21:44:46 +0200 |
commit | 3bf22d31148ab077d34fa0a94b3f9e926719e81b (patch) | |
tree | 461c86d50f034de48f132a0a3a4a7a89ef716c15 /tests/pos | |
parent | 58e2c9b429dc53a865fdcfd60459966513110058 (diff) | |
download | dotty-3bf22d31148ab077d34fa0a94b3f9e926719e81b.tar.gz dotty-3bf22d31148ab077d34fa0a94b3f9e926719e81b.tar.bz2 dotty-3bf22d31148ab077d34fa0a94b3f9e926719e81b.zip |
Move the inlining of value class methods before Erasure
VCInline is split into two phases:
- VCInlineMethods (before Erasure) replaces value class method calls
by calls to extension methods
- VCElideAllocations (after Erasure) handles == and optimizing the
unboxing of a boxed value class, as VCInline did before.
This should not affect anything currently, but in the future we will have
phases before Erasure that mangle names (like TypeSpecializer, see #630),
being able to put these phases after VCInlineMethods means that
VCInlineMethods does not need to know anything about how these phases
mangle names, this reduces the coupling between phases. The trade-off is
that VCInlineMethods needs to deal with type parameters and multiple
parameter lists whereas VCInline didn't.
Diffstat (limited to 'tests/pos')
-rw-r--r-- | tests/pos/valueclasses/paramlists.scala | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/pos/valueclasses/paramlists.scala b/tests/pos/valueclasses/paramlists.scala new file mode 100644 index 000000000..f390a44e0 --- /dev/null +++ b/tests/pos/valueclasses/paramlists.scala @@ -0,0 +1,37 @@ +package paramlists + +class Meter[T](val x: T) extends AnyVal { + def zero: T = x + def zero2[M >: T]: M = x + def one(): T = x + def one2[M >: T](): M = x + def one3(x: T): T = x + def one4[M >: T](x: M): M = x + def two(x: T)(y: T): T = y + def two2[M >: T](x: T)(y: M): M = y +} + +object Test { + def test: Unit = { + val m1 = new Meter(1) + m1.zero + m1.zero2 + m1.one + m1.one2 + m1.one3(10) + m1.two(11)(12) + m1.two2(11)(12) + + { + import m1._ + + zero + zero2 + one + one2 + one3(10) + two(11)(12) + two2(11)(12) + } + } +} |