diff options
author | Nicolas Stucki <nicolas.stucki@gmail.com> | 2017-02-09 14:45:42 +0100 |
---|---|---|
committer | Nicolas Stucki <nicolas.stucki@gmail.com> | 2017-02-13 18:29:02 +0100 |
commit | 93a2d0653e6b74a0f88825ac8a522da87e474f2a (patch) | |
tree | 7a97d30544f09083ec0561478bf49b78fb44f2ab /compiler/src/dotty/tools/dotc/core/TypeErasure.scala | |
parent | b29783237c03ade1dd19cc564170c7a87d7b8b84 (diff) | |
download | dotty-93a2d0653e6b74a0f88825ac8a522da87e474f2a.tar.gz dotty-93a2d0653e6b74a0f88825ac8a522da87e474f2a.tar.bz2 dotty-93a2d0653e6b74a0f88825ac8a522da87e474f2a.zip |
Add checks for synthetic functions and erased functions.
* Add `isSyntheticFunction` checks for synthetic functions such as FuntionN
for N > 22 and ImplicitFunctionN for N >= 0.
* Add `erasedFunctionClass` to get the erased verion of synthetic functions.
* Change the semantics of `isFunctionClass` to return true if it is any kind of
FunctionN or ImplicitFunctionN.
Diffstat (limited to 'compiler/src/dotty/tools/dotc/core/TypeErasure.scala')
-rw-r--r-- | compiler/src/dotty/tools/dotc/core/TypeErasure.scala | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala index 2a341390b..ff99008bb 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeErasure.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeErasure.scala @@ -44,7 +44,7 @@ object TypeErasure { val sym = tp.symbol sym.isClass && sym != defn.AnyClass && sym != defn.ArrayClass && - !defn.isXXLFunctionClass(sym) && !defn.isImplicitFunctionClass(sym) + !defn.isSyntheticFunctionClass(sym) case _: TermRef => true case JavaArrayType(elem) => @@ -358,8 +358,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean if (!sym.isClass) this(tp.info) else if (semiEraseVCs && isDerivedValueClass(sym)) eraseDerivedValueClassRef(tp) else if (sym == defn.ArrayClass) apply(tp.appliedTo(TypeBounds.empty)) // i966 shows that we can hit a raw Array type. - else if (defn.isXXLFunctionClass(sym)) defn.FunctionXXLType - else if (defn.isImplicitFunctionClass(sym)) apply(defn.FunctionType(sym.name.functionArity)) + else if (defn.isSyntheticFunctionClass(sym)) defn.erasedFunctionType(sym) else eraseNormalClassRef(tp) case tp: RefinedType => val parent = tp.parent @@ -370,7 +369,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean case SuperType(thistpe, supertpe) => SuperType(this(thistpe), this(supertpe)) case ExprType(rt) => - defn.FunctionClass(0).typeRef + defn.FunctionType(0) case AndType(tp1, tp2) => erasedGlb(this(tp1), this(tp2), isJava) case OrType(tp1, tp2) => @@ -496,8 +495,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean val erasedVCRef = eraseDerivedValueClassRef(tp) if (erasedVCRef.exists) return sigName(erasedVCRef) } - if (defn.isImplicitFunctionClass(sym)) - sigName(defn.FunctionType(sym.name.functionArity)) + if (defn.isSyntheticFunctionClass(sym)) + sigName(defn.erasedFunctionType(sym)) else normalizeClass(sym.asClass).fullName.asTypeName case defn.ArrayOf(elem) => |