Skip to content

Commit c9671ac

Browse files
committed
Handle erasure of implicit function types
1 parent de9519f commit c9671ac

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/src/dotty/tools/dotc/core/TypeErasure.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package dotty.tools
22
package dotc
33
package core
44

5-
import Symbols._, Types._, Contexts._, Flags._, Names._, StdNames._, Decorators._, Flags.JavaDefined
5+
import Symbols._, Types._, Contexts._, Flags._, Names._, StdNames._, Decorators._
6+
import Flags.JavaDefined
7+
import NameOps._
68
import Uniques.unique
79
import dotc.transform.ExplicitOuter._
810
import dotc.transform.ValueClasses._
@@ -327,6 +329,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
327329
* - For a typeref scala.Any, scala.AnyVal or scala.Singleton: |java.lang.Object|
328330
* - For a typeref scala.Unit, |scala.runtime.BoxedUnit|.
329331
* - For a typeref scala.FunctionN, where N > MaxImplementedFunctionArity, scala.FunctionXXL
332+
* - For a typeref scala.ImplicitFunctionN, | scala.FunctionN |
330333
* - For a typeref P.C where C refers to a class, <noprefix> # C.
331334
* - For a typeref P.C where C refers to an alias type, the erasure of C's alias.
332335
* - For a typeref P.C where C refers to an abstract type, the erasure of C's upper bound.
@@ -356,6 +359,7 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
356359
else if (semiEraseVCs && isDerivedValueClass(sym)) eraseDerivedValueClassRef(tp)
357360
else if (sym == defn.ArrayClass) apply(tp.appliedTo(TypeBounds.empty)) // i966 shows that we can hit a raw Array type.
358361
else if (defn.isUnimplementedFunctionClass(sym)) defn.FunctionXXLType
362+
else if (defn.isImplicitFunctionClass(sym)) apply(defn.FunctionType(sym.name.functionArity))
359363
else eraseNormalClassRef(tp)
360364
case tp: RefinedType =>
361365
val parent = tp.parent
@@ -492,7 +496,10 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
492496
val erasedVCRef = eraseDerivedValueClassRef(tp)
493497
if (erasedVCRef.exists) return sigName(erasedVCRef)
494498
}
495-
normalizeClass(sym.asClass).fullName.asTypeName
499+
if (defn.isImplicitFunctionClass(sym))
500+
sigName(defn.FunctionType(sym.name.functionArity))
501+
else
502+
normalizeClass(sym.asClass).fullName.asTypeName
496503
case defn.ArrayOf(elem) =>
497504
sigName(this(tp))
498505
case JavaArrayType(elem) =>

0 commit comments

Comments
 (0)