@@ -23,6 +23,7 @@ import config.Config
23
23
import util .common ._
24
24
import collection .mutable .ListBuffer
25
25
import Decorators .SymbolIteratorDecorator
26
+ import SymDenotations .LazyType
26
27
27
28
/** Denotations represent the meaning of symbols and named types.
28
29
* The following diagram shows how the principal types of denotations
@@ -171,12 +172,19 @@ object Denotations {
171
172
*
172
173
* @param symbol The referencing symbol, or NoSymbol is none exists
173
174
*/
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 {
176
176
type AsSeenFromResult <: Denotation
177
177
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
+ }
180
188
181
189
/** The type info, or, if this is a SymDenotation where the symbol
182
190
* is not yet completed, the completer
@@ -657,7 +665,7 @@ object Denotations {
657
665
}
658
666
659
667
/** A non-overloaded denotation */
660
- abstract class SingleDenotation (symbol : Symbol ) extends Denotation (symbol) {
668
+ abstract class SingleDenotation (symbol : Symbol , initInfo : Type ) extends Denotation (symbol, initInfo ) {
661
669
protected def newLikeThis (symbol : Symbol , info : Type ): SingleDenotation
662
670
663
671
final def name (implicit ctx : Context ): Name = symbol.name
@@ -1081,34 +1089,32 @@ object Denotations {
1081
1089
}
1082
1090
}
1083
1091
1084
- abstract class NonSymSingleDenotation (symbol : Symbol ) extends SingleDenotation (symbol) {
1085
- def infoOrCompleter : Type
1086
- def info (implicit ctx : Context ) = infoOrCompleter
1092
+ abstract class NonSymSingleDenotation (symbol : Symbol , initInfo : Type ) extends SingleDenotation (symbol, initInfo) {
1093
+ def infoOrCompleter : Type = initInfo
1087
1094
def isType = infoOrCompleter.isInstanceOf [TypeType ]
1088
1095
}
1089
1096
1090
1097
class UniqueRefDenotation (
1091
1098
symbol : Symbol ,
1092
- val infoOrCompleter : Type ,
1093
- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1099
+ initInfo : Type ,
1100
+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
1094
1101
validFor = initValidFor
1095
1102
override def hasUniqueSym : Boolean = true
1096
1103
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new UniqueRefDenotation (s, i, validFor)
1097
1104
}
1098
1105
1099
1106
class JointRefDenotation (
1100
1107
symbol : Symbol ,
1101
- val infoOrCompleter : Type ,
1102
- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1108
+ initInfo : Type ,
1109
+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
1103
1110
validFor = initValidFor
1104
1111
override def hasUniqueSym = false
1105
1112
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new JointRefDenotation (s, i, validFor)
1106
1113
}
1107
1114
1108
- class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol ) {
1115
+ class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol , NoType ) {
1109
1116
override def exists = false
1110
1117
override def hasUniqueSym = false
1111
- def infoOrCompleter = NoType
1112
1118
validFor = Period .allInRun(ctx.runId)
1113
1119
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = this
1114
1120
}
@@ -1190,9 +1196,9 @@ object Denotations {
1190
1196
1191
1197
/** An overloaded denotation consisting of the alternatives of both given denotations.
1192
1198
*/
1193
- case class MultiDenotation (denot1 : Denotation , denot2 : Denotation ) extends Denotation (NoSymbol ) with MultiPreDenotation {
1199
+ case class MultiDenotation (denot1 : Denotation , denot2 : Denotation ) extends Denotation (NoSymbol , NoType ) with MultiPreDenotation {
1194
1200
final def infoOrCompleter = multiHasNot(" info" )
1195
- final def info (implicit ctx : Context ) = infoOrCompleter
1201
+ // final def info(implicit ctx: Context) = infoOrCompleter
1196
1202
final def validFor = denot1.validFor & denot2.validFor
1197
1203
final def isType = false
1198
1204
final def hasUniqueSym = false
0 commit comments