@@ -54,8 +54,9 @@ trait Deriving {
5454 // If we set the Synthetic flag here widenGiven will widen too far and the
5555 // derived instance will have too low a priority to be selected over a freshly
5656 // derived instance at the summoning site.
57+ val flags = if info.isInstanceOf [MethodOrPoly ] then Given | Method else Given | Lazy
5758 synthetics +=
58- newSymbol(ctx.owner, instanceName, Given | Method , info, coord = pos.span)
59+ newSymbol(ctx.owner, instanceName, flags , info, coord = pos.span)
5960 .entered
6061 }
6162
@@ -96,8 +97,7 @@ trait Deriving {
9697 def addInstance (derivedParams : List [TypeSymbol ], evidenceParamInfos : List [List [Type ]], instanceTypes : List [Type ]): Unit = {
9798 val resultType = typeClassType.appliedTo(instanceTypes)
9899 val monoInfo =
99- if evidenceParamInfos.isEmpty then
100- if derivedParams.isEmpty then ExprType (resultType) else resultType
100+ if evidenceParamInfos.isEmpty then resultType
101101 else ImplicitMethodType (evidenceParamInfos.map(typeClassType.appliedTo), resultType)
102102 val derivedInfo =
103103 if derivedParams.isEmpty then monoInfo
@@ -295,7 +295,8 @@ trait Deriving {
295295 }
296296
297297 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 ))
299300 }
300301
301302 synthetics.map(syntheticDef).toList
0 commit comments