aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/TypeErasure.scala
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2015-04-17 21:55:25 +0200
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2015-05-01 13:27:42 +0200
commit449055db733a78a44b15addc3ddcbb51bfdc3aa4 (patch)
treea8589aa345f2512ca060bf9b1df1b39eecbd02e0 /src/dotty/tools/dotc/core/TypeErasure.scala
parente5b02a88e66af0d5e9c37a881ac0237bf1d38387 (diff)
downloaddotty-449055db733a78a44b15addc3ddcbb51bfdc3aa4.tar.gz
dotty-449055db733a78a44b15addc3ddcbb51bfdc3aa4.tar.bz2
dotty-449055db733a78a44b15addc3ddcbb51bfdc3aa4.zip
Fix companionClass not working after Erasure for value classes
For a module class V$, the synthesized companion class method looks like: val companion$class: V If V is a value class, after erasure it will look like: val companion$class: ErasedValueType(V, ...) This will break SymDenotation#companionClass which relies on the type of companion$class. The solution is to not semi-erase the type of companion$class.
Diffstat (limited to 'src/dotty/tools/dotc/core/TypeErasure.scala')
-rw-r--r--src/dotty/tools/dotc/core/TypeErasure.scala6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeErasure.scala b/src/dotty/tools/dotc/core/TypeErasure.scala
index 1ea63465a..e695e6721 100644
--- a/src/dotty/tools/dotc/core/TypeErasure.scala
+++ b/src/dotty/tools/dotc/core/TypeErasure.scala
@@ -142,11 +142,15 @@ object TypeErasure {
* - For $asInstanceOf : [T]T
* - For $isInstanceOf : [T]Boolean
* - For all abstract types : = ?
+ * - For COMPANION_CLASS_METHOD : the erasure of their type with semiEraseVCs = false,
+ * this is needed to keep [[SymDenotation#companionClass]]
+ * working after erasure for value classes.
* - For all other symbols : the semi-erasure of their types, with
* isJava, isConstructor set according to symbol.
*/
def transformInfo(sym: Symbol, tp: Type)(implicit ctx: Context): Type = {
- val erase = erasureFn(sym is JavaDefined, semiEraseVCs = true, sym.isConstructor, wildcardOK = false)
+ val semiEraseVCs = sym.name ne nme.COMPANION_CLASS_METHOD
+ val erase = erasureFn(sym is JavaDefined, semiEraseVCs, sym.isConstructor, wildcardOK = false)
def eraseParamBounds(tp: PolyType): Type =
tp.derivedPolyType(