@@ -301,10 +301,31 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
301
301
}
302
302
}
303
303
304
+ /** Is this type a path with some part that is initialized on use? */
305
+ def isLateInitialized (tp : Type ): Boolean = tp.dealias match {
306
+ case tp : TermRef =>
307
+ tp.symbol.isLateInitialized || isLateInitialized(tp.prefix)
308
+ case _ : SingletonType | NoPrefix =>
309
+ false
310
+ case tp : TypeRef =>
311
+ true
312
+ case tp : TypeProxy =>
313
+ isLateInitialized(tp.underlying)
314
+ case tp : AndOrType =>
315
+ isLateInitialized(tp.tp1) || isLateInitialized(tp.tp2)
316
+ case _ =>
317
+ true
318
+ }
319
+
304
320
/** The realizability status of given type `tp`*/
305
321
def realizability (tp : Type ): Realizability = tp.dealias match {
306
322
case tp : TermRef =>
307
- if (tp.symbol.isRealizable) Realizable
323
+ if (tp.symbol.isRealizable)
324
+ if (tp.symbol.isLateInitialized || // we already checked realizability of info in that case
325
+ ! isLateInitialized(tp.prefix)) // symbol was definitely constructed in that case
326
+ Realizable
327
+ else
328
+ realizability(tp.info)
308
329
else if (! tp.symbol.isStable) NotStable
309
330
else if (! tp.symbol.isEffectivelyFinal) new NotFinal (tp.symbol)
310
331
else new ProblemInUnderlying (tp.info, realizability(tp.info))
@@ -335,6 +356,18 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
335
356
}
336
357
}
337
358
359
+ /* Might need at some point in the future
360
+ def memberRealizability(tp: Type)(implicit ctx: Context) = {
361
+ println(i"check member rel of $tp")
362
+ def isUnrealizable(fld: SingleDenotation) =
363
+ !fld.symbol.is(Lazy) && realizability(fld.info) != Realizable
364
+ tp.fields.find(isUnrealizable) match {
365
+ case Some(fld) => new HasProblemField(fld)
366
+ case _ => Realizable
367
+ }
368
+ }
369
+ */
370
+
338
371
private def enterArgBinding (formal : Symbol , info : Type , cls : ClassSymbol , decls : Scope ) = {
339
372
val lazyInfo = new LazyType { // needed so we do not force `formal`.
340
373
def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
@@ -567,9 +600,14 @@ object TypeOps {
567
600
class NotFinal (sym : Symbol )(implicit ctx : Context )
568
601
extends Realizability (i " refers to nonfinal $sym" )
569
602
570
- class HasProblemBounds (mbr : SingleDenotation )(implicit ctx : Context )
571
- extends Realizability (i " has a member $mbr with possibly conflicting bounds ${mbr .info.bounds.lo} <: ... <: ${mbr .info.bounds.hi}" )
603
+ class HasProblemBounds (typ : SingleDenotation )(implicit ctx : Context )
604
+ extends Realizability (i " has a member $typ with possibly conflicting bounds ${typ .info.bounds.lo} <: ... <: ${typ .info.bounds.hi}" )
572
605
606
+ /* Might need at some point in the future
607
+ class HasProblemField(fld: SingleDenotation)(implicit ctx: Context)
608
+ extends Realizability(i" has a member $fld which is uneligible as a path since ${fld.symbol.name}${ctx.realizability(fld.info)}")
609
+ */
610
+
573
611
class ProblemInUnderlying (tp : Type , problem : Realizability )(implicit ctx : Context )
574
612
extends Realizability (i " s underlying type ${tp}${problem.msg}" )
575
613
}
0 commit comments