@@ -7,6 +7,7 @@ import ast._
77import Trees ._ , StdNames ._ , Scopes ._ , Denotations ._ , Comments ._
88import Contexts ._ , Symbols ._ , Types ._ , SymDenotations ._ , Names ._ , NameOps ._ , Flags ._ , Decorators ._
99import NameKinds .DefaultGetterName
10+ import TypeApplications .TypeParamInfo
1011import ast .desugar , ast .desugar ._
1112import ProtoTypes ._
1213import util .Spans ._
@@ -977,43 +978,33 @@ class Namer { typer: Typer =>
977978 */
978979 def addForwarder (alias : TermName , mbr : SingleDenotation , span : Span ): Unit =
979980 if (whyNoForwarder(mbr) == " " ) {
980-
981- /** The info of a forwarder to type `ref` which has info `info`
982- */
983- def fwdInfo (ref : Type , info : Type ): Type = info match {
984- case _ : ClassInfo =>
985- HKTypeLambda .fromParams(info.typeParams, ref)
986- case _ : TypeBounds =>
987- TypeAlias (ref)
988- case info : HKTypeLambda =>
989- info.derivedLambdaType(info.paramNames, info.paramInfos,
990- fwdInfo(ref.appliedTo(info.paramRefs), info.resultType))
991- case info => // should happen only in error cases
992- info
993- }
994-
981+ val sym = mbr.symbol
995982 val forwarder =
996983 if (mbr.isType)
997984 ctx.newSymbol(
998985 cls, alias.toTypeName,
999986 Exported | Final ,
1000- fwdInfo (path.tpe.select(mbr.symbol), mbr.info ),
987+ TypeAlias (path.tpe.select(sym) ),
1001988 coord = span)
989+ // Note: This will always create unparameterzied aliases. So even if the original type is
990+ // a parameterized class, say `C[X]` the alias will read `type C = d.C`. We currently do
991+ // allow such type aliases. If we forbid them at some point (requiring the referred type to be
992+ // fully applied), we'd have to change the scheme here as well.
1002993 else {
1003994 val (maybeStable, mbrInfo) =
1004- if (mbr.symbol. isStableMember && mbr.symbol .isPublic)
1005- (StableRealizable , ExprType (path.tpe.select(mbr.symbol )))
995+ if (sym. isStableMember && sym .isPublic)
996+ (StableRealizable , ExprType (path.tpe.select(sym )))
1006997 else
1007998 (EmptyFlags , mbr.info.ensureMethodic)
1008- val mbrFlags = Exported | Method | Final | maybeStable | mbr.symbol .flags & RetainedExportFlags
999+ val mbrFlags = Exported | Method | Final | maybeStable | sym .flags & RetainedExportFlags
10091000 ctx.newSymbol(cls, alias, mbrFlags, mbrInfo, coord = span)
10101001 }
10111002 forwarder.info = avoidPrivateLeaks(forwarder)
10121003 val forwarderDef =
10131004 if (forwarder.isType) tpd.TypeDef (forwarder.asType)
10141005 else {
10151006 import tpd ._
1016- val ref = path.select(mbr.symbol .asTerm)
1007+ val ref = path.select(sym .asTerm)
10171008 tpd.polyDefDef(forwarder.asTerm, targs => prefss =>
10181009 ref.appliedToTypes(targs).appliedToArgss(prefss)
10191010 )
0 commit comments