@@ -18,6 +18,7 @@ import scala.collection.mutable.ListBuffer
1818import symtab .Flags ._
1919import scala .reflect .internal .util .FreshNameCreator
2020import scala .reflect .internal .util .ListOfNil
21+ import scala .util .chaining ._
2122
2223/** XXX to resolve: TreeGen only assumes global is a SymbolTable, but
2324 * TreeDSL at the moment expects a Global. Can we get by with SymbolTable?
@@ -371,16 +372,16 @@ abstract class TreeGen extends scala.reflect.internal.TreeGen with TreeDSL {
371372 if (isFunction || typeSym.isSubClass(SerializableClass ))
372373 anonClass.addAnnotation(SerialVersionUIDAnnotation )
373374
374- anonClass.setInfo(fun.tpe match {
375- case tpe @ RefinedType (parents, scope) =>
376- assert(scope.forall(_.isType), s " Cannot expand function of type $tpe " )
377- ClassInfoType (parents, scope, anonClass )
378- case tpe =>
379- val parents =
380- if (! isFunction) tpe :: Nil
381- else addSerializable(abstractFunctionType(fun.vparams.map(_.symbol.tpe), fun.body.tpe.deconst))
382- ClassInfoType (parents, newScope, anonClass)
383- } )
375+ val rScope = newScope
376+ def parents ( tp : Type ) : List [ Type ] = tp match {
377+ case RefinedType (ps, scope) =>
378+ assert( scope.forall(_.isType), s " Cannot expand function of type $tp " )
379+ ps.flatMap(parents).tap(_ => scope.foreach(rScope.enter))
380+ case _ =>
381+ if (! isFunction) tp :: Nil
382+ else addSerializable(abstractFunctionType(fun.vparams.map(_.symbol.tpe), fun.body.tpe.deconst))
383+ }
384+ anonClass.setInfo( ClassInfoType (parents(fun.tpe), rScope, anonClass) )
384385
385386 // The original owner is used in the backend for the EnclosingMethod attribute. If fun is
386387 // nested in a value-class method, its owner was already changed to the extension method.
0 commit comments