@@ -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,44 +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- if (info.typeParams.isEmpty) TypeAlias (ref)
986- else HKTypeLambda .fromParams(info.typeParams, ref)
987- case _ : TypeBounds =>
988- TypeAlias (ref)
989- case info : HKTypeLambda =>
990- info.derivedLambdaType(info.paramNames, info.paramInfos,
991- fwdInfo(ref.appliedTo(info.paramRefs), info.resultType))
992- case info => // should happen only in error cases
993- info
994- }
995-
981+ val sym = mbr.symbol
996982 val forwarder =
997983 if (mbr.isType)
998984 ctx.newSymbol(
999985 cls, alias.toTypeName,
1000986 Exported | Final ,
1001- fwdInfo (path.tpe.select(mbr.symbol), mbr.info ),
987+ TypeAlias (path.tpe.select(sym) ),
1002988 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.
1003993 else {
1004994 val (maybeStable, mbrInfo) =
1005- if (mbr.symbol. isStableMember && mbr.symbol .isPublic)
1006- (StableRealizable , ExprType (path.tpe.select(mbr.symbol )))
995+ if (sym. isStableMember && sym .isPublic)
996+ (StableRealizable , ExprType (path.tpe.select(sym )))
1007997 else
1008998 (EmptyFlags , mbr.info.ensureMethodic)
1009- val mbrFlags = Exported | Method | Final | maybeStable | mbr.symbol .flags & RetainedExportFlags
999+ val mbrFlags = Exported | Method | Final | maybeStable | sym .flags & RetainedExportFlags
10101000 ctx.newSymbol(cls, alias, mbrFlags, mbrInfo, coord = span)
10111001 }
10121002 forwarder.info = avoidPrivateLeaks(forwarder)
10131003 val forwarderDef =
10141004 if (forwarder.isType) tpd.TypeDef (forwarder.asType)
10151005 else {
10161006 import tpd ._
1017- val ref = path.select(mbr.symbol .asTerm)
1007+ val ref = path.select(sym .asTerm)
10181008 tpd.polyDefDef(forwarder.asTerm, targs => prefss =>
10191009 ref.appliedToTypes(targs).appliedToArgss(prefss)
10201010 )
0 commit comments