From 06e18c6e7761c458b33af3471f013a4dd3cee3f1 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Wed, 30 Dec 2015 20:45:21 +0100 Subject: Avoid infinite subtyping checks when intersecting denotations This allows us to run compileStdLib without deep subtypes again. --- src/dotty/tools/dotc/core/Denotations.scala | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/dotty/tools/dotc/core/Denotations.scala') diff --git a/src/dotty/tools/dotc/core/Denotations.scala b/src/dotty/tools/dotc/core/Denotations.scala index fcd60ef16..00ad90354 100644 --- a/src/dotty/tools/dotc/core/Denotations.scala +++ b/src/dotty/tools/dotc/core/Denotations.scala @@ -259,11 +259,12 @@ object Denotations { * * If there is no preferred accessible denotation, return a JointRefDenotation * with one of the operand symbols (unspecified which one), and an info which - * is intersection (&) of the infos of the operand denotations. + * is the intersection (using `&` or `safe_&` if `safeIntersection` is true) + * of the infos of the operand denotations. * * If SingleDenotations with different signatures are joined, return NoDenotation. */ - def & (that: Denotation, pre: Type)(implicit ctx: Context): Denotation = { + def & (that: Denotation, pre: Type, safeIntersection: Boolean = false)(implicit ctx: Context): Denotation = { /** Try to merge denot1 and denot2 without adding a new signature. */ def mergeDenot(denot1: Denotation, denot2: SingleDenotation): Denotation = denot1 match { @@ -317,7 +318,11 @@ object Denotations { else if (preferSym(sym2, sym1)) sym2 else sym1 val jointInfo = - try info1 & info2 + try + if (safeIntersection) + info1 safe_& info2 + else + info1 & info2 catch { case ex: MergeError => if (pre.widen.classSymbol.is(Scala2x) || ctx.scala2Mode) -- cgit v1.2.3