@@ -3,7 +3,7 @@ package dotc
3
3
package core
4
4
5
5
import Contexts ._ , Types ._ , Symbols ._ , Names ._ , Flags ._ , Scopes ._
6
- import SymDenotations ._ , Denotations .Denotation
6
+ import SymDenotations ._ , Denotations .SingleDenotation
7
7
import config .Printers ._
8
8
import util .Positions ._
9
9
import Decorators ._
@@ -341,96 +341,6 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
341
341
}
342
342
}
343
343
344
- /** A type is volatile if its DNF contains an alternative of the form
345
- * {P1, ..., Pn}, {N1, ..., Nk}, where the Pi are parent typerefs and the
346
- * Nj are refinement names, and one the 4 following conditions is met:
347
- *
348
- * 1. At least two of the parents Pi are abstract types.
349
- * 2. One of the parents Pi is an abstract type, and one other type Pj,
350
- * j != i has an abstract member which has the same name as an
351
- * abstract member of the whole type.
352
- * 3. One of the parents Pi is an abstract type, and one of the refinement
353
- * names Nj refers to an abstract member of the whole type.
354
- * 4. One of the parents Pi is an an alias type with a volatile alias
355
- * or an abstract type with a volatile upper bound.
356
- *
357
- * Lazy values are not allowed to have volatile type, as otherwise
358
- * unsoundness can result.
359
- */
360
- final def isVolatile (tp : Type ): Boolean = {
361
-
362
- /** Pre-filter to avoid expensive DNF computation
363
- * If needsChecking returns false it is guaranteed that
364
- * DNF does not contain intersections, or abstract types with upper
365
- * bounds that themselves need checking.
366
- */
367
- def needsChecking (tp : Type , isPart : Boolean ): Boolean = tp match {
368
- case tp : TypeRef =>
369
- tp.info match {
370
- case TypeAlias (alias) =>
371
- needsChecking(alias, isPart)
372
- case TypeBounds (lo, hi) =>
373
- isPart || tp.controlled(isVolatile(hi))
374
- case _ => false
375
- }
376
- case tp : RefinedType =>
377
- needsChecking(tp.parent, true )
378
- case tp : TypeProxy =>
379
- needsChecking(tp.underlying, isPart)
380
- case tp : AndType =>
381
- true
382
- case tp : OrType =>
383
- isPart || needsChecking(tp.tp1, isPart) && needsChecking(tp.tp2, isPart)
384
- case _ =>
385
- false
386
- }
387
-
388
- needsChecking(tp, false ) && {
389
- DNF (tp) forall { case (parents, refinedNames) =>
390
- val absParents = parents filter (_.symbol is Deferred )
391
- absParents.nonEmpty && {
392
- absParents.lengthCompare(2 ) >= 0 || {
393
- val ap = absParents.head
394
- ((parents exists (p =>
395
- (p ne ap)
396
- || p.memberNames(abstractTypeNameFilter, tp).nonEmpty
397
- || p.memberNames(abstractTermNameFilter, tp).nonEmpty))
398
- || (refinedNames & tp.memberNames(abstractTypeNameFilter, tp)).nonEmpty
399
- || (refinedNames & tp.memberNames(abstractTermNameFilter, tp)).nonEmpty
400
- || isVolatile(ap))
401
- }
402
- }
403
- }
404
- }
405
- }
406
-
407
- /** The disjunctive normal form of this type.
408
- * This collects a set of alternatives, each alternative consisting
409
- * of a set of typerefs and a set of refinement names. Both sets are represented
410
- * as lists, to obtain a deterministic order. Collected are
411
- * all type refs reachable by following aliases and type proxies, and
412
- * collecting the elements of conjunctions (&) and disjunctions (|).
413
- * The set of refinement names in each alternative
414
- * are the set of names in refinement types encountered during the collection.
415
- */
416
- final def DNF (tp : Type ): List [(List [TypeRef ], Set [Name ])] = ctx.traceIndented(s " DNF( $this) " , checks) {
417
- tp.dealias match {
418
- case tp : TypeRef =>
419
- (tp :: Nil , Set [Name ]()) :: Nil
420
- case RefinedType (parent, name) =>
421
- for ((ps, rs) <- DNF (parent)) yield (ps, rs + name)
422
- case tp : TypeProxy =>
423
- DNF (tp.underlying)
424
- case AndType (l, r) =>
425
- for ((lps, lrs) <- DNF (l); (rps, rrs) <- DNF (r))
426
- yield (lps | rps, lrs | rrs)
427
- case OrType (l, r) =>
428
- DNF (l) | DNF (r)
429
- case tp =>
430
- TypeOps .emptyDNF
431
- }
432
- }
433
-
434
344
private def enterArgBinding (formal : Symbol , info : Type , cls : ClassSymbol , decls : Scope ) = {
435
345
val lazyInfo = new LazyType { // needed so we do not force `formal`.
436
346
def complete (denot : SymDenotation )(implicit ctx : Context ): Unit = {
@@ -644,10 +554,8 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
644
554
if (scala2Mode) migrationWarning(msg, pos)
645
555
scala2Mode
646
556
}
647
-
648
557
}
649
558
650
559
object TypeOps {
651
- val emptyDNF = (Nil , Set [Name ]()) :: Nil
652
560
@ sharable var track = false // !!!DEBUG
653
561
}
0 commit comments