Skip to content

Commit

Permalink
Merge pull request #331 from dotty-staging/fix/refined-subtyping
Browse files Browse the repository at this point in the history
Fix/refined subtyping
  • Loading branch information
odersky committed Jan 31, 2015
2 parents 537c53b + 70e55d2 commit a822fc1
Show file tree
Hide file tree
Showing 44 changed files with 2,144 additions and 1,219 deletions.
6 changes: 4 additions & 2 deletions src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
1 change: 1 addition & 0 deletions src/dotty/tools/dotc/Run.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ object desugar {
case tp: NamedType if tp.symbol.owner eq originalOwner =>
val defctx = ctx.outersIterator.dropWhile(_.scope eq ctx.scope).next
var local = defctx.denotNamed(tp.name).suchThat(_ is ParamOrAccessor).symbol
typr.println(s"rewiring ${tp.symbol} from ${originalOwner.showLocated} to ${local.showLocated}, current owner = ${ctx.owner.showLocated}")
if (local.exists) (defctx.owner.thisType select local).dealias
else throw new Error(s"no matching symbol for ${sym.showLocated} in ${defctx.owner} / ${defctx.effectiveScope}")
case _ =>
Expand Down
41 changes: 32 additions & 9 deletions src/dotty/tools/dotc/config/Config.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,34 @@ object Config {

final val checkCacheMembersNamed = false

final val checkConstraintsNonCyclic = true

final val flagInstantiationToNothing = false
/** When updating a connstraint bound, check that the constrained parameter
* does not appear at the top-level of either of its bounds.
*/
final val checkConstraintsNonCyclic = false

/** Like `checkConstraintsNonCyclic`, but all constrained parameters
* are tested for direct or indirect dependencies, each time a
* constraint is added in TypeComparer.
*/
final val checkConstraintsNonCyclicTrans = false

/** Check that each constraint resulting from a subtype test
* is satisfiable.
*/
final val checkConstraintsSatisfiable = false

/** Check that each constraint is fully propagated. i.e.
* If P <: Q then the upper bound of P is a subtype of the upper bound of Q
* and the lower bound of Q is a subtype of the lower bound of P.
*/
final val checkConstraintsPropagated = false

/** Type comparer will fail with an assert if the upper bound
* of a constrained parameter becomes Nothing. This should be turned
* on only for specific debugging as normally instantiation to Nothing
* is not an error consdition.
*/
final val failOnInstantiationToNothing = false

/** Enable noDoubleDef checking if option "-YnoDoubleDefs" is set.
* The reason to have an option as well as the present global switch is
Expand All @@ -24,7 +49,11 @@ object Config {
/** Show subtype traces for all deep subtype recursions */
final val traceDeepSubTypeRecursions = false

/** When explaining subtypes and this flag is set, also show the classes of the compared types. */
final val verboseExplainSubtype = true

/** If this flag is set, take the fast path when comparing same-named type-aliases and types */
final val fastPathForRefinedSubtype = true

/** When set, use new signature-based matching.
* Advantantage of doing so: It's supposed to be faster
Expand All @@ -35,12 +64,6 @@ object Config {
/** The recursion depth for showing a summarized string */
final val summarizeDepth = 2

/** Track dependencies for constraint propagation satisfiability checking
* If turned off, constraint checking is simpler but potentially slower
* for large constraints.
*/
final val trackConstrDeps = true

/** Check that variances of lambda arguments match the
* variance of the underlying lambda class.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class ScalaSettings extends Settings.SettingGroup {
val Yrepldebug = BooleanSetting("-Yrepl-debug", "Trace all repl activity.")
val Ytyperdebug = BooleanSetting("-Ytyper-debug", "Trace all type assignments.")
val Ypatmatdebug = BooleanSetting("-Ypatmat-debug", "Trace pattern matching translation.")
val Yexplainlowlevel = BooleanSetting("-Yexplainlowlevel", "When explaining type errors, show types at a lower level.")
val Yexplainlowlevel = BooleanSetting("-Yexplain-lowlevel", "When explaining type errors, show types at a lower level.")
val YnoDoubleBindings = BooleanSetting("-YnoDoubleBindings", "Assert no namedtype is bound twice (should be enabled only if program is error-free).")

val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying optimisations to the program") withAbbreviation "-optimize"
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Constants.scala
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ object Constants {
def convertTo(pt: Type)(implicit ctx: Context): Constant = {
def lowerBound(pt: Type): Type = pt.dealias.stripTypeVar match {
case tref: TypeRef if !tref.symbol.isClass => lowerBound(tref.info.bounds.lo)
case param: PolyParam => lowerBound(ctx.typeComparer.bounds(param).lo)
case param: PolyParam => lowerBound(ctx.typerState.constraint.nonParamBounds(param).lo)
case pt => pt
}
val target = lowerBound(pt).typeSymbol
Expand Down
Loading

0 comments on commit a822fc1

Please sign in to comment.