Skip to content

Commit 16e2066

Browse files
committed
Fix types of generated deriving methods
Avoid generating them with a PolyType over an ExpreType. Instead of `[T] (=> U)` we should generate `[T]U`. That's what we do for all user-defined types.
1 parent ed826a7 commit 16e2066

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

compiler/src/dotty/tools/dotc/typer/Deriving.scala

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,13 @@ trait Deriving {
9595

9696
def addInstance(derivedParams: List[TypeSymbol], evidenceParamInfos: List[List[Type]], instanceTypes: List[Type]): Unit = {
9797
val resultType = typeClassType.appliedTo(instanceTypes)
98-
val methodOrExpr =
99-
if (evidenceParamInfos.isEmpty) ExprType(resultType)
98+
val monoInfo =
99+
if evidenceParamInfos.isEmpty then
100+
if derivedParams.isEmpty then ExprType(resultType) else resultType
100101
else ImplicitMethodType(evidenceParamInfos.map(typeClassType.appliedTo), resultType)
101-
val derivedInfo = if (derivedParams.isEmpty) methodOrExpr else PolyType.fromParams(derivedParams, methodOrExpr)
102+
val derivedInfo =
103+
if derivedParams.isEmpty then monoInfo
104+
else PolyType.fromParams(derivedParams, monoInfo)
102105
addDerivedInstance(originalTypeClassType.typeSymbol.name, derivedInfo, derived.srcPos)
103106
}
104107

0 commit comments

Comments
 (0)