@@ -657,6 +657,7 @@ class ClassfileParser(
657657 var constant : Constant = null
658658 var exceptions : List [NameOrString ] = Nil
659659 var annotations : List [Annotation ] = Nil
660+ var namedParams : Map [Int , TermName ] = Map .empty
660661 def complete (tp : Type , isVarargs : Boolean = false )(using Context ): Type = {
661662 val updatedType =
662663 if sig == null then tp
@@ -680,7 +681,14 @@ class ClassfileParser(
680681 sym.addAnnotation(ThrowsAnnotation (cls.asClass))
681682 }
682683
683- cook.apply(newType)
684+ def fillInParamNames (t : Type ): Type = t match
685+ case mt @ MethodType (oldp) if namedParams.nonEmpty =>
686+ mt.derivedLambdaType(List .tabulate(oldp.size)(n => namedParams.getOrElse(n, oldp(n))))
687+ case pt : PolyType if namedParams.nonEmpty =>
688+ pt.derivedLambdaType(pt.paramNames, pt.paramInfos, fillInParamNames(pt.resultType))
689+ case _ => t
690+
691+ cook.apply(fillInParamNames(newType))
684692 }
685693 }
686694
@@ -714,6 +722,14 @@ class ClassfileParser(
714722 if (c ne null ) res.constant = c
715723 else report.warning(s " Invalid constant in attribute of ${sym.showLocated} while parsing ${classfile}" )
716724
725+ case tpnme.MethodParametersATTR =>
726+ val paramCount = in.nextByte
727+ for i <- 0 until paramCount do
728+ val name = pool.getName(in.nextChar)
729+ val flags = in.nextChar
730+ if (flags & JAVA_ACC_SYNTHETIC ) == 0 then
731+ res.namedParams += (i -> name.name)
732+
717733 case tpnme.AnnotationDefaultATTR =>
718734 sym.addAnnotation(Annotation (defn.AnnotationDefaultAnnot , Nil ))
719735
0 commit comments