@@ -23,6 +23,7 @@ import config.Config
2323import util .common ._
2424import collection .mutable .ListBuffer
2525import Decorators .SymbolIteratorDecorator
26+ import SymDenotations .LazyType
2627
2728/** Denotations represent the meaning of symbols and named types.
2829 * The following diagram shows how the principal types of denotations
@@ -171,12 +172,19 @@ object Denotations {
171172 *
172173 * @param symbol The referencing symbol, or NoSymbol is none exists
173174 */
174- abstract class Denotation (val symbol : Symbol ) extends PreDenotation with printing.Showable {
175-
175+ abstract class Denotation (val symbol : Symbol , protected var myInfo : Type ) extends PreDenotation with printing.Showable {
176176 type AsSeenFromResult <: Denotation
177177
178- /** The type info of the denotation, exists only for non-overloaded denotations */
179- def info (implicit ctx : Context ): Type
178+ /** The type info.
179+ * The info is an instance of TypeType iff this is a type denotation
180+ * Uncompleted denotations set myInfo to a LazyType.
181+ */
182+ final def info (implicit ctx : Context ): Type = {
183+ def completeInfo = { // Written this way so that `info` is small enough to be inlined
184+ this .asInstanceOf [SymDenotation ].completeFrom(myInfo.asInstanceOf [LazyType ]); info
185+ }
186+ if (myInfo.isInstanceOf [LazyType ]) completeInfo else myInfo
187+ }
180188
181189 /** The type info, or, if this is a SymDenotation where the symbol
182190 * is not yet completed, the completer
@@ -676,7 +684,7 @@ object Denotations {
676684 }
677685
678686 /** A non-overloaded denotation */
679- abstract class SingleDenotation (symbol : Symbol ) extends Denotation (symbol) {
687+ abstract class SingleDenotation (symbol : Symbol , initInfo : Type ) extends Denotation (symbol, initInfo ) {
680688 protected def newLikeThis (symbol : Symbol , info : Type ): SingleDenotation
681689
682690 final def name (implicit ctx : Context ): Name = symbol.name
@@ -1100,34 +1108,32 @@ object Denotations {
11001108 }
11011109 }
11021110
1103- abstract class NonSymSingleDenotation (symbol : Symbol ) extends SingleDenotation (symbol) {
1104- def infoOrCompleter : Type
1105- def info (implicit ctx : Context ) = infoOrCompleter
1111+ abstract class NonSymSingleDenotation (symbol : Symbol , initInfo : Type ) extends SingleDenotation (symbol, initInfo) {
1112+ def infoOrCompleter : Type = initInfo
11061113 def isType = infoOrCompleter.isInstanceOf [TypeType ]
11071114 }
11081115
11091116 class UniqueRefDenotation (
11101117 symbol : Symbol ,
1111- val infoOrCompleter : Type ,
1112- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1118+ initInfo : Type ,
1119+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
11131120 validFor = initValidFor
11141121 override def hasUniqueSym : Boolean = true
11151122 protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new UniqueRefDenotation (s, i, validFor)
11161123 }
11171124
11181125 class JointRefDenotation (
11191126 symbol : Symbol ,
1120- val infoOrCompleter : Type ,
1121- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1127+ initInfo : Type ,
1128+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
11221129 validFor = initValidFor
11231130 override def hasUniqueSym = false
11241131 protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new JointRefDenotation (s, i, validFor)
11251132 }
11261133
1127- class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol ) {
1134+ class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol , NoType ) {
11281135 override def exists = false
11291136 override def hasUniqueSym = false
1130- def infoOrCompleter = NoType
11311137 validFor = Period .allInRun(ctx.runId)
11321138 protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = this
11331139 }
@@ -1203,9 +1209,8 @@ object Denotations {
12031209
12041210 /** An overloaded denotation consisting of the alternatives of both given denotations.
12051211 */
1206- case class MultiDenotation (denot1 : Denotation , denot2 : Denotation ) extends Denotation (NoSymbol ) with MultiPreDenotation {
1212+ case class MultiDenotation (denot1 : Denotation , denot2 : Denotation ) extends Denotation (NoSymbol , NoType ) with MultiPreDenotation {
12071213 final def infoOrCompleter = multiHasNot(" info" )
1208- final def info (implicit ctx : Context ) = infoOrCompleter
12091214 final def validFor = denot1.validFor & denot2.validFor
12101215 final def isType = false
12111216 final def hasUniqueSym = false
0 commit comments