@@ -342,10 +342,31 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
342
342
}
343
343
}
344
344
345
+ /** Is this type a path with some part that is initialized on use? */
346
+ def isLateInitialized (tp : Type ): Boolean = tp.dealias match {
347
+ case tp : TermRef =>
348
+ tp.symbol.isLateInitialized || isLateInitialized(tp.prefix)
349
+ case _ : SingletonType | NoPrefix =>
350
+ false
351
+ case tp : TypeRef =>
352
+ true
353
+ case tp : TypeProxy =>
354
+ isLateInitialized(tp.underlying)
355
+ case tp : AndOrType =>
356
+ isLateInitialized(tp.tp1) || isLateInitialized(tp.tp2)
357
+ case _ =>
358
+ true
359
+ }
360
+
345
361
/** The realizability status of given type `tp`*/
346
362
def realizability (tp : Type ): Realizability = tp.dealias match {
347
363
case tp : TermRef =>
348
- if (tp.symbol.isRealizable) Realizable
364
+ if (tp.symbol.isRealizable)
365
+ if (tp.symbol.isLateInitialized || // we already checked realizability of info in that case
366
+ ! isLateInitialized(tp.prefix)) // symbol was definitely constructed in that case
367
+ Realizable
368
+ else
369
+ realizability(tp.info)
349
370
else if (! tp.symbol.isStable) NotStable
350
371
else if (! tp.symbol.isEffectivelyFinal) new NotFinal (tp.symbol)
351
372
else new ProblemInUnderlying (tp.info, realizability(tp.info))
@@ -376,6 +397,18 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
376
397
}
377
398
}
378
399
400
+ /* Might need at some point in the future
401
+ def memberRealizability(tp: Type)(implicit ctx: Context) = {
402
+ println(i"check member rel of $tp")
403
+ def isUnrealizable(fld: SingleDenotation) =
404
+ !fld.symbol.is(Lazy) && realizability(fld.info) != Realizable
405
+ tp.fields.find(isUnrealizable) match {
406
+ case Some(fld) => new HasProblemField(fld)
407
+ case _ => Realizable
408
+ }
409
+ }
410
+ */
411
+
379
412
private def enterArgBinding (formal : Symbol , info : Type , cls : ClassSymbol , decls : Scope ) = {
380
413
val lazyInfo = new LazyType { // needed so we do not force `formal`.
381
414
def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
@@ -608,9 +641,14 @@ object TypeOps {
608
641
class NotFinal (sym : Symbol )(implicit ctx : Context )
609
642
extends Realizability (i " refers to nonfinal $sym" )
610
643
611
- class HasProblemBounds (mbr : SingleDenotation )(implicit ctx : Context )
612
- extends Realizability (i " has a member $mbr with possibly conflicting bounds ${mbr .info.bounds.lo} <: ... <: ${mbr .info.bounds.hi}" )
644
+ class HasProblemBounds (typ : SingleDenotation )(implicit ctx : Context )
645
+ extends Realizability (i " has a member $typ with possibly conflicting bounds ${typ .info.bounds.lo} <: ... <: ${typ .info.bounds.hi}" )
613
646
647
+ /* Might need at some point in the future
648
+ class HasProblemField(fld: SingleDenotation)(implicit ctx: Context)
649
+ extends Realizability(i" has a member $fld which is uneligible as a path since ${fld.symbol.name}${ctx.realizability(fld.info)}")
650
+ */
651
+
614
652
class ProblemInUnderlying (tp : Type , problem : Realizability )(implicit ctx : Context )
615
653
extends Realizability (i " s underlying type ${tp}${problem.msg}" )
616
654
}
0 commit comments