@@ -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
@@ -676,7 +684,7 @@ object Denotations {
676
684
}
677
685
678
686
/** 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 ) {
680
688
protected def newLikeThis (symbol : Symbol , info : Type ): SingleDenotation
681
689
682
690
final def name (implicit ctx : Context ): Name = symbol.name
@@ -1100,34 +1108,32 @@ object Denotations {
1100
1108
}
1101
1109
}
1102
1110
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
1106
1113
def isType = infoOrCompleter.isInstanceOf [TypeType ]
1107
1114
}
1108
1115
1109
1116
class UniqueRefDenotation (
1110
1117
symbol : Symbol ,
1111
- val infoOrCompleter : Type ,
1112
- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1118
+ initInfo : Type ,
1119
+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
1113
1120
validFor = initValidFor
1114
1121
override def hasUniqueSym : Boolean = true
1115
1122
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new UniqueRefDenotation (s, i, validFor)
1116
1123
}
1117
1124
1118
1125
class JointRefDenotation (
1119
1126
symbol : Symbol ,
1120
- val infoOrCompleter : Type ,
1121
- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1127
+ initInfo : Type ,
1128
+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
1122
1129
validFor = initValidFor
1123
1130
override def hasUniqueSym = false
1124
1131
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new JointRefDenotation (s, i, validFor)
1125
1132
}
1126
1133
1127
- class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol ) {
1134
+ class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol , NoType ) {
1128
1135
override def exists = false
1129
1136
override def hasUniqueSym = false
1130
- def infoOrCompleter = NoType
1131
1137
validFor = Period .allInRun(ctx.runId)
1132
1138
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = this
1133
1139
}
@@ -1203,9 +1209,8 @@ object Denotations {
1203
1209
1204
1210
/** An overloaded denotation consisting of the alternatives of both given denotations.
1205
1211
*/
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 {
1207
1213
final def infoOrCompleter = multiHasNot(" info" )
1208
- final def info (implicit ctx : Context ) = infoOrCompleter
1209
1214
final def validFor = denot1.validFor & denot2.validFor
1210
1215
final def isType = false
1211
1216
final def hasUniqueSym = false
0 commit comments