@@ -54,8 +54,9 @@ trait Deriving {
54
54
// If we set the Synthetic flag here widenGiven will widen too far and the
55
55
// derived instance will have too low a priority to be selected over a freshly
56
56
// derived instance at the summoning site.
57
+ val flags = if info.isInstanceOf [MethodOrPoly ] then Given | Method else Given | Lazy
57
58
synthetics +=
58
- newSymbol(ctx.owner, instanceName, Given | Method , info, coord = pos.span)
59
+ newSymbol(ctx.owner, instanceName, flags , info, coord = pos.span)
59
60
.entered
60
61
}
61
62
@@ -96,8 +97,7 @@ trait Deriving {
96
97
def addInstance (derivedParams : List [TypeSymbol ], evidenceParamInfos : List [List [Type ]], instanceTypes : List [Type ]): Unit = {
97
98
val resultType = typeClassType.appliedTo(instanceTypes)
98
99
val monoInfo =
99
- if evidenceParamInfos.isEmpty then
100
- if derivedParams.isEmpty then ExprType (resultType) else resultType
100
+ if evidenceParamInfos.isEmpty then resultType
101
101
else ImplicitMethodType (evidenceParamInfos.map(typeClassType.appliedTo), resultType)
102
102
val derivedInfo =
103
103
if derivedParams.isEmpty then monoInfo
@@ -295,7 +295,8 @@ trait Deriving {
295
295
}
296
296
297
297
def syntheticDef (sym : Symbol ): Tree = inContext(ctx.fresh.setOwner(sym).setNewScope) {
298
- tpd.polyDefDef(sym.asTerm, typeclassInstance(sym))
298
+ if sym.is(Method ) then tpd.polyDefDef(sym.asTerm, typeclassInstance(sym))
299
+ else tpd.ValDef (sym.asTerm, typeclassInstance(sym)(Nil )(Nil ))
299
300
}
300
301
301
302
synthetics.map(syntheticDef).toList
0 commit comments