@@ -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
@@ -646,7 +654,7 @@ object Denotations {
646
654
}
647
655
648
656
/** A non-overloaded denotation */
649
- abstract class SingleDenotation (symbol : Symbol ) extends Denotation (symbol) {
657
+ abstract class SingleDenotation (symbol : Symbol , initInfo : Type ) extends Denotation (symbol, initInfo ) {
650
658
protected def newLikeThis (symbol : Symbol , info : Type ): SingleDenotation
651
659
652
660
final def name (implicit ctx : Context ): Name = symbol.name
@@ -1076,34 +1084,32 @@ object Denotations {
1076
1084
}
1077
1085
}
1078
1086
1079
- abstract class NonSymSingleDenotation (symbol : Symbol ) extends SingleDenotation (symbol) {
1080
- def infoOrCompleter : Type
1081
- def info (implicit ctx : Context ) = infoOrCompleter
1087
+ abstract class NonSymSingleDenotation (symbol : Symbol , initInfo : Type ) extends SingleDenotation (symbol, initInfo) {
1088
+ def infoOrCompleter : Type = initInfo
1082
1089
def isType = infoOrCompleter.isInstanceOf [TypeType ]
1083
1090
}
1084
1091
1085
1092
class UniqueRefDenotation (
1086
1093
symbol : Symbol ,
1087
- val infoOrCompleter : Type ,
1088
- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1094
+ initInfo : Type ,
1095
+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
1089
1096
validFor = initValidFor
1090
1097
override def hasUniqueSym : Boolean = true
1091
1098
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new UniqueRefDenotation (s, i, validFor)
1092
1099
}
1093
1100
1094
1101
class JointRefDenotation (
1095
1102
symbol : Symbol ,
1096
- val infoOrCompleter : Type ,
1097
- initValidFor : Period ) extends NonSymSingleDenotation (symbol) {
1103
+ initInfo : Type ,
1104
+ initValidFor : Period ) extends NonSymSingleDenotation (symbol, initInfo ) {
1098
1105
validFor = initValidFor
1099
1106
override def hasUniqueSym = false
1100
1107
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = new JointRefDenotation (s, i, validFor)
1101
1108
}
1102
1109
1103
- class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol ) {
1110
+ class ErrorDenotation (implicit ctx : Context ) extends NonSymSingleDenotation (NoSymbol , NoType ) {
1104
1111
override def exists = false
1105
1112
override def hasUniqueSym = false
1106
- def infoOrCompleter = NoType
1107
1113
validFor = Period .allInRun(ctx.runId)
1108
1114
protected def newLikeThis (s : Symbol , i : Type ): SingleDenotation = this
1109
1115
}
@@ -1185,9 +1191,9 @@ object Denotations {
1185
1191
1186
1192
/** An overloaded denotation consisting of the alternatives of both given denotations.
1187
1193
*/
1188
- case class MultiDenotation (denot1 : Denotation , denot2 : Denotation ) extends Denotation (NoSymbol ) with MultiPreDenotation {
1194
+ case class MultiDenotation (denot1 : Denotation , denot2 : Denotation ) extends Denotation (NoSymbol , NoType ) with MultiPreDenotation {
1189
1195
final def infoOrCompleter = multiHasNot(" info" )
1190
- final def info (implicit ctx : Context ) = infoOrCompleter
1196
+ // final def info(implicit ctx: Context) = infoOrCompleter
1191
1197
final def validFor = denot1.validFor & denot2.validFor
1192
1198
final def isType = false
1193
1199
final def hasUniqueSym = false
0 commit comments