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