@@ -7,6 +7,7 @@ import ast._
7
7
import Trees ._ , StdNames ._ , Scopes ._ , Denotations ._ , Comments ._
8
8
import Contexts ._ , Symbols ._ , Types ._ , SymDenotations ._ , Names ._ , NameOps ._ , Flags ._ , Decorators ._
9
9
import NameKinds .DefaultGetterName
10
+ import TypeApplications .TypeParamInfo
10
11
import ast .desugar , ast .desugar ._
11
12
import ProtoTypes ._
12
13
import util .Spans ._
@@ -977,44 +978,33 @@ class Namer { typer: Typer =>
977
978
*/
978
979
def addForwarder (alias : TermName , mbr : SingleDenotation , span : Span ): Unit =
979
980
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
996
982
val forwarder =
997
983
if (mbr.isType)
998
984
ctx.newSymbol(
999
985
cls, alias.toTypeName,
1000
986
Exported | Final ,
1001
- fwdInfo (path.tpe.select(mbr.symbol), mbr.info ),
987
+ TypeAlias (path.tpe.select(sym) ),
1002
988
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.
1003
993
else {
1004
994
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 )))
1007
997
else
1008
998
(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
1010
1000
ctx.newSymbol(cls, alias, mbrFlags, mbrInfo, coord = span)
1011
1001
}
1012
1002
forwarder.info = avoidPrivateLeaks(forwarder)
1013
1003
val forwarderDef =
1014
1004
if (forwarder.isType) tpd.TypeDef (forwarder.asType)
1015
1005
else {
1016
1006
import tpd ._
1017
- val ref = path.select(mbr.symbol .asTerm)
1007
+ val ref = path.select(sym .asTerm)
1018
1008
tpd.polyDefDef(forwarder.asTerm, targs => prefss =>
1019
1009
ref.appliedToTypes(targs).appliedToArgss(prefss)
1020
1010
)
0 commit comments