aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2015-01-19 09:09:23 +0100
committerMartin Odersky <odersky@gmail.com>2015-01-19 09:09:23 +0100
commit5354f88c6ef2dafd5ae876c16c9758155a780783 (patch)
treea21475558d4d8fa532ad50a18311e213a14ab30c /src
parent9b260d087a4c63c39e404fd6ba7ade286fdfd8e8 (diff)
downloaddotty-5354f88c6ef2dafd5ae876c16c9758155a780783.tar.gz
dotty-5354f88c6ef2dafd5ae876c16c9758155a780783.tar.bz2
dotty-5354f88c6ef2dafd5ae876c16c9758155a780783.zip
Fixed soundness hole in TypeComparer
Two named types with same names and NoPrefix prefixes are not necessarily equal! The fix uncovered an error in tailrec. When run on Decorators.scala, tailrec in its old position at the end of a group produces not -Ycheckable code. Problem was fixed by moving TailRec into its own group.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala6
-rw-r--r--src/dotty/tools/dotc/Run.scala1
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala9
3 files changed, 12 insertions, 4 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index 943b54d7f..c5c1d8713 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -45,8 +45,10 @@ class Compiler {
List(new RefChecks,
new ElimRepeated,
new ElimLocals,
- new ExtensionMethods,
- new TailRec),
+ new ExtensionMethods),
+ List(new TailRec), // TailRec needs to be in its own group for now.
+ // Otherwise it produces -Ycheck incorrect code for
+ // file core/Decorators.scala.
List(new PatternMatcher,
new ExplicitOuter,
new Splitter),
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index f7d89e897..abee30aab 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -46,6 +46,7 @@ class Run(comp: Compiler)(implicit ctx: Context) {
.filterNot(ctx.settings.Yskip.value.containsPhase(_)) // TODO: skip only subphase
for (phase <- phasesToRun)
if (!ctx.reporter.hasErrors) {
+ if (ctx.settings.verbose.value) println(s"[$phase]")
units = phase.runOn(units)
def foreachUnit(op: Context => Unit)(implicit ctx: Context): Unit =
for (unit <- units) op(ctx.fresh.setPhase(phase.next).setCompilationUnit(unit))
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index faeef559c..720e372d2 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -167,8 +167,13 @@ class TypeComparer(initctx: Context) extends DotClass with ConstraintHandling wi
)
}
)
- else (tp1.name eq tp2.name) && isSameType(tp1.prefix, tp2.prefix)
- ) || isHKSubType || secondTryNamed(tp1, tp2)
+ else
+ (tp1.name eq tp2.name) &&
+ isSameType(tp1.prefix, tp2.prefix) &&
+ (tp1.signature == tp1.signature) &&
+ !tp1.isInstanceOf[WithFixedSym] &&
+ !tp2.isInstanceOf[WithFixedSym]
+ ) || isHKSubType || secondTryNamed(tp1, tp2)
case tp1: ThisType if tp1.cls eq tp2.symbol.moduleClass =>
isSubType(tp1.cls.owner.thisType, tp2.prefix)
case _ =>