@@ -10,6 +10,7 @@ import scala.quoted._
1010import SymOps ._
1111import NameNormalizer ._
1212import SyntheticsSupport ._
13+ import dotty .tools .dotc .core .NameKinds
1314
1415trait ClassLikeSupport :
1516 self : TastyParser =>
@@ -612,20 +613,21 @@ trait ClassLikeSupport:
612613 contextBounds : Map [String , DSignature ] = Map .empty,
613614 )
614615
615- def isSyntheticEvidence (name : String ) = name.startsWith(" evidence$" )
616616
617617 def unwrapMemberInfo (c : ClassDef , symbol : Symbol ): MemberInfo =
618618 val baseTypeRepr = memberInfo(c, symbol)
619619
620+ def isSyntheticEvidence (name : String ) =
621+ if ! name.startsWith(NameKinds .EvidenceParamName .separator) then false else
622+ symbol.paramSymss.flatten.find(_.name == name).exists(_.flags.is(Flags .Implicit ))
623+
620624 def handlePolyType (polyType : PolyType ): MemberInfo =
621625 MemberInfo (polyType.paramNames.zip(polyType.paramBounds).toMap, List .empty, polyType.resType)
622626
623627 def handleMethodType (memberInfo : MemberInfo , methodType : MethodType ): MemberInfo =
624628 val rawParams = methodType.paramNames.zip(methodType.paramTypes).toMap
625- val (evidences, newParams) = rawParams.partition(e => isSyntheticEvidence(e._1))
626- val newLists : List [ParameterList ] = if newParams.isEmpty && evidences.nonEmpty
627- then memberInfo.paramLists ++ Seq (EvidenceOnlyParameterList )
628- else memberInfo.paramLists ++ Seq (newParams)
629+ val (evidences, notEvidences) = rawParams.partition(e => isSyntheticEvidence(e._1))
630+
629631
630632 def findParamRefs (t : TypeRepr ): Seq [ParamRef ] = t match
631633 case paramRef : ParamRef => Seq (paramRef)
@@ -638,17 +640,25 @@ trait ClassLikeSupport:
638640 val PolyType (names, _, _) = ref.binder
639641 names(ref.paramNum)
640642
641- val contextBounds =
642- evidences.collect {
643+ val (paramsThatLookLikeContextBounds, contextBounds) =
644+ evidences.partitionMap {
643645 case (_, AppliedType (tpe, List (typeParam : ParamRef ))) =>
644- nameForRef(typeParam) -> tpe.asSignature
645- case (_, original) =>
646- val typeParam = findParamRefs(original).head // TODO throw nicer error!
647- val name = nameForRef(typeParam)
648- val signature = Seq (s " ([ $name] =>> " ) ++ original.asSignature ++ Seq (" )" )
649- name -> signature
646+ Right (nameForRef(typeParam) -> tpe.asSignature)
647+ case (name, original) =>
648+ findParamRefs(original) match
649+ case Nil => Left ((name, original))
650+ case typeParam :: _ =>
651+ val name = nameForRef(typeParam)
652+ val signature = Seq (s " ([ $name] =>> " ) ++ original.asSignature ++ Seq (" )" )
653+ Right (name -> signature)
650654 }
651655
656+ val newParams = notEvidences ++ paramsThatLookLikeContextBounds
657+
658+ val newLists : List [ParameterList ] = if newParams.isEmpty && contextBounds.nonEmpty
659+ then memberInfo.paramLists ++ Seq (EvidenceOnlyParameterList )
660+ else memberInfo.paramLists ++ Seq (newParams)
661+
652662 MemberInfo (memberInfo.genericTypes, newLists , methodType.resType, contextBounds.toMap)
653663
654664 def handleByNameType (memberInfo : MemberInfo , byNameType : ByNameType ): MemberInfo =
0 commit comments