Skip to content

Commit a5b1eee

Browse files
committed
Don't try to simplify & / | types written as types
We should leave an explicit & or | type as an AndType or OrType. Failure to do this led to cyclic references when compiling stdlib. Question to resolve: Should we disable all sorts of simplifications when compiling a type tree?
1 parent 19c3b21 commit a5b1eee

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

compiler/src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
115115
tp.derivedRefinedType(simplify(tp.parent, theMap), tp.refinedName, simplify(tp.refinedInfo, theMap))
116116
case tp: TypeAlias =>
117117
tp.derivedTypeAlias(simplify(tp.alias, theMap))
118-
case AndType(l, r) =>
118+
case AndType(l, r) if !ctx.mode.is(Mode.Type) =>
119119
simplify(l, theMap) & simplify(r, theMap)
120-
case OrType(l, r) =>
120+
case OrType(l, r) if !ctx.mode.is(Mode.Type) =>
121121
simplify(l, theMap) | simplify(r, theMap)
122122
case _ =>
123123
(if (theMap != null) theMap else new SimplifyMap).mapOver(tp)

compiler/src/dotty/tools/dotc/typer/TypeAssigner.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ trait TypeAssigner {
468468
tree.withType(ref.tpe)
469469

470470
def assignType(tree: untpd.AndTypeTree, left: Tree, right: Tree)(implicit ctx: Context) =
471-
tree.withType(inSameUniverse(_ & _, left.tpe, right, "an `&`"))
471+
tree.withType(inSameUniverse(AndType(_, _), left.tpe, right, "an `&`"))
472472

473473
def assignType(tree: untpd.OrTypeTree, left: Tree, right: Tree)(implicit ctx: Context) =
474-
tree.withType(inSameUniverse(_ | _, left.tpe, right, "an `|`"))
474+
tree.withType(inSameUniverse(OrType(_, _), left.tpe, right, "an `|`"))
475475

476476
/** Assign type of RefinedType.
477477
* Refinements are typed as if they were members of refinement class `refineCls`.

0 commit comments

Comments
 (0)