aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/core/Types.scala
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2013-06-19 05:00:48 +0200
committerMartin Odersky <odersky@gmail.com>2013-06-19 05:00:48 +0200
commitfdf09cd6a3240645f0bd7a42d455331d148eb95d (patch)
treef1087f32136261bfc5bff6a94a1bb78cdd973957 /src/dotty/tools/dotc/core/Types.scala
parentb2dcc777e5a6a1e6d1fff89c7fa794129ad5d135 (diff)
downloaddotty-fdf09cd6a3240645f0bd7a42d455331d148eb95d.tar.gz
dotty-fdf09cd6a3240645f0bd7a42d455331d148eb95d.tar.bz2
dotty-fdf09cd6a3240645f0bd7a42d455331d148eb95d.zip
made ClassInfo#typeConstructor work more directly.
Replaced asSeenFrom by a direct copy of the underlying denotation, and added a cache for the result.
Diffstat (limited to 'src/dotty/tools/dotc/core/Types.scala')
-rw-r--r--src/dotty/tools/dotc/core/Types.scala13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/dotty/tools/dotc/core/Types.scala b/src/dotty/tools/dotc/core/Types.scala
index 851eb1301..f39821d84 100644
--- a/src/dotty/tools/dotc/core/Types.scala
+++ b/src/dotty/tools/dotc/core/Types.scala
@@ -1530,9 +1530,16 @@ object Types {
if ((prefix eq cls.owner.thisType) || !cls.owner.isClass) tp
else tp.substThis(cls.owner.asClass, prefix)
- def typeConstructor(implicit ctx: Context): Type =
- if ((cls is PackageClass) || cls.owner.isTerm) TypeRef.withSym(prefix, cls)
- else TypeRef(prefix, cls.name).withDenot(cls.denot.asSeenFrom(prefix)) // this ???
+ private var tyconCache: Type = null
+
+ def typeConstructor(implicit ctx: Context): Type = {
+ def clsDenot = if (prefix eq cls.owner.thisType) cls.denot else cls.denot.copySymDenotation(info = this)
+ if (tyconCache == null)
+ tyconCache =
+ if ((cls is PackageClass) || cls.owner.isTerm) TypeRef.withSym(prefix, cls)
+ else TypeRef(prefix, cls.name).withDenot(clsDenot)
+ tyconCache
+ }
// cached because baseType needs parents
private var parentsCache: List[TypeRef] = null