summaryrefslogtreecommitdiff
path: root/test/files/run/delambdafy_t6028.check
diff options
context:
space:
mode:
authorAdriaan Moors <adriaan.moors@typesafe.com>2016-02-10 11:46:15 -0800
committerAdriaan Moors <adriaan.moors@typesafe.com>2016-02-10 11:46:15 -0800
commitda3f7177232e7c0732d5b7d2929dbb8271d7b395 (patch)
tree71b1f31626991ed3b9cd92af6bd6605588866f8c /test/files/run/delambdafy_t6028.check
parent78c378c97c51600cac1cf42edd050aceb2366026 (diff)
downloadscala-da3f7177232e7c0732d5b7d2929dbb8271d7b395.tar.gz
scala-da3f7177232e7c0732d5b7d2929dbb8271d7b395.tar.bz2
scala-da3f7177232e7c0732d5b7d2929dbb8271d7b395.zip
Towards understanding `TypeRef`'s `transformInfo`/`baseType`
By reducing excessive factoring, we can save an extraneous call to `asSeenFrom`, and hopefully in a following commit figure out a bigger problem with `baseType` that is causing wrong subtyping results. This commit is a pure refactoring, save for the dropped ASF call, which is explained below. To motivate the following change to `relativeInfo`: ``` private[Types] def relativeInfo = /*trace(s"relativeInfo(${safeToString}})")*/{ if (relativeInfoPeriod != currentPeriod) { - val memberInfo = pre.memberInfo(sym) - relativeInfoCache = transformInfo(memberInfo) + relativeInfoCache = memberInfoInstantiated ``` Let's consolidate the two removed line in this new method: ``` def memberInfoInstantiated = transformInfo(pre.memberInfo(sym)) ``` To understand what `transformInfo` does, take these helpers spread over various `*TypeRef` traits, and consolidate them: ``` - def asSeenFromOwner(tp: Type) = tp.asSeenFrom(pre, sym.owner) // regular type refs: - def transformInfo(tp: Type): Type = appliedType(asSeenFromOwner(tp), args) // for no-args type refs: - override def transformInfo(tp: Type): Type = appliedType(asSeenFromOwner(tp), dummyArgs) ``` By removing the dynamic dispatch, we get the following method (given `require(args0 ne Nil, this)` in `ArgsTypeRef`, and `args eq Nil` by construction in `NoArgsTypeRef` ): ``` def transformInfo(tp: Type) = appliedType(tp.asSeenFrom(pre, sym.owner), if (args.isEmpty) dummyArgs else args) ``` Inlining `memberInfo`, which is defined as: ``` def memberInfo(sym: Symbol): Type = { require(sym ne NoSymbol, this) sym.info.asSeenFrom(this, sym.owner) } ``` gives us: ``` def memberInfoInstantiated = transformInfo(sym.info.asSeenFrom(pre, sym.owner)) ``` Inlining `transformInfo` as reworked above: ``` def memberInfoInstantiated = appliedType(sym.info.asSeenFrom(pre, sym.owner).asSeenFrom(pre, sym.owner), if (args.isEmpty) dummyArgs else args) ``` Whoops! One `asSeenFrom` should do... ``` + final protected def memberInfoInstantiated: Type = + appliedType(sym.info.asSeenFrom(pre, sym.owner), if (args.isEmpty) dummyArgs else args) ```
Diffstat (limited to 'test/files/run/delambdafy_t6028.check')
0 files changed, 0 insertions, 0 deletions