diff --git a/bench/profiles/stdlib.yml b/bench/profiles/stdlib.yml new file mode 100644 index 000000000000..bffcd5b86968 --- /dev/null +++ b/bench/profiles/stdlib.yml @@ -0,0 +1,15 @@ +charts: + + - name: "scala stdlib-2.13" + url: https://github.com/dotty-staging/scala/commits/stdLib213-dotty-community-build + lines: + - key: stdlib213 + label: bootstrapped + +scripts: + + stdlib213: + - source $PROG_HOME/dotty/bench/scripts/stdlib213 + +config: + pr_base_url: "https://github.com/lampepfl/dotty/pull/" diff --git a/compiler/src/dotty/tools/dotc/Run.scala b/compiler/src/dotty/tools/dotc/Run.scala index 6b51908c37d7..e143ea5891ab 100644 --- a/compiler/src/dotty/tools/dotc/Run.scala +++ b/compiler/src/dotty/tools/dotc/Run.scala @@ -202,7 +202,10 @@ class Run(comp: Compiler, ictx: Context) extends ImplicitRunInfo with Constraint Stats.trackTime(s"$phase ms ") { val start = System.currentTimeMillis val profileBefore = profiler.beforePhase(phase) - units = phase.runOn(units) + + // invariant: constraint should not cross phase boundary + ctx.typerState.ensureSegregated { units = phase.runOn(units) } + profiler.afterPhase(phase, profileBefore) if (ctx.settings.Xprint.value.containsPhase(phase)) for (unit <- units) diff --git a/compiler/src/dotty/tools/dotc/core/TyperState.scala b/compiler/src/dotty/tools/dotc/core/TyperState.scala index 8b4b6a476d1b..4b8751a38b5e 100644 --- a/compiler/src/dotty/tools/dotc/core/TyperState.scala +++ b/compiler/src/dotty/tools/dotc/core/TyperState.scala @@ -159,5 +159,18 @@ class TyperState() { s"TS[${ids(this).mkString(", ")}]" } + /** Execute the operation with an empty constraint and make sure no leak + * of constraints. + * + * Side effect: the method will reset the constraint associated with the context. + */ + def ensureSegregated[T](op: => T)(using Context): T = + this.constraint = OrderingConstraint.empty + val res = op + // force instantiate tvars + // see tests/pos/t2619b.scala + ctx.typerState.gc() + res + def stateChainStr: String = s"$this${if (previous == null) "" else previous.stateChainStr}" } diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 8a0b0f12c167..49abfbce5957 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -4019,7 +4019,14 @@ object Types { case tycon: TypeRef if tycon.symbol.isOpaqueAlias => tycon.translucentSuperType.applyIfParameterized(args) case _ => - tryNormalize.orElse(superType) + val x = tryNormalize + if x.exists then + record("try norm OK") + record(i"try norm OK $x") + x + else + record("try norm KO") + superType } inline def map(inline op: Type => Type)(using Context) = @@ -4038,6 +4045,9 @@ object Types { case tycon: TypeRef => def tryMatchAlias = tycon.info match { case MatchAlias(alias) => + record(i"try match alias") + record(i"try match alias $this in ${ctx.owner.ownersIterator.toList}%, %") + //new Error().printStackTrace() trace(i"normalize $this", typr, show = true) { MatchTypeTrace.recurseWith(this) { alias.applyIfParameterized(args).tryNormalize diff --git a/tests/pos/t2619b.scala b/tests/pos/t2619b.scala new file mode 100644 index 000000000000..e1519669a52a --- /dev/null +++ b/tests/pos/t2619b.scala @@ -0,0 +1,8 @@ +abstract class AbstractModule + +object ModuleBE extends AbstractModule +object ModuleBF extends AbstractModule + +object ModuleBM extends AbstractModule { + def ms: List[AbstractModule] = List(ModuleBE) ::: List(ModuleBF) +}