Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/refined subtyping #331

Merged
merged 72 commits into from
Jan 31, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7c40b03
test reorg
odersky Dec 21, 2014
9d8e473
Handle subtyping cases involving null.
odersky Dec 22, 2014
e50f47c
Better name for pattern
odersky Dec 31, 2014
e3a4380
Reorg of subtyping.
odersky Jan 1, 2015
95f74c2
Provide the correct levels for RefinedThis types.
odersky Jan 1, 2015
390ac42
Removed debug println
odersky Jan 1, 2015
6543f89
Make use of refinementRefersToThis in lookupRefinement.
odersky Jan 1, 2015
bd405e5
Extended refinementRefersToThis to alias types.
odersky Jan 1, 2015
9c1d486
isSubType reorg
odersky Jan 1, 2015
a7a603f
Show level for RefinedThis
odersky Jan 3, 2015
14f6eb0
Make findMember depend on RefinedThis level.
odersky Jan 3, 2015
2085ebb
Deleted diagnostics output that caused cyclic references
odersky Jan 6, 2015
5e61149
Fixed bug that caused error message to be suppressed.
odersky Jan 7, 2015
74b2584
Add deSkolemize method.
odersky Jan 8, 2015
1309f0f
Add transitive check for cycles in constraints.
odersky Jan 8, 2015
0a35baa
New scheme for subtyping refined types.
odersky Jan 8, 2015
979ff5e
Simplify and fix bounds propagation in constraints.
odersky Jan 8, 2015
0bc9f68
Remove choice between new and old scheme for subtyping refined types.
odersky Jan 8, 2015
9f74533
Refacttored skolemization logic
odersky Jan 8, 2015
90f2668
Optimize for case where RefinedThis is absent
odersky Jan 9, 2015
cb103db
Fix problem in constraint handling
odersky Jan 9, 2015
53db7c8
New fast path for checking refined types.
odersky Jan 9, 2015
f11a0a5
Remove unnecessary nested methods in TypeComparer.
odersky Jan 9, 2015
ee191f3
Made fast path for refined subtype checking configurable.
odersky Jan 9, 2015
3c159db
Simplification for lookupRefined
odersky Jan 9, 2015
2ae7f2a
More aggressive reduction in lookupRefinedThis.
odersky Jan 9, 2015
acb64b2
TypeComparer cleanups.
odersky Jan 9, 2015
710e40e
Made refinement subtype fastpath insensitive to RefineedThis#binder.
odersky Jan 9, 2015
4429243
Removed some checks
odersky Jan 10, 2015
5f35b11
Split off ConstraintHandling into separate trait.
odersky Jan 10, 2015
97aced0
Reverting the idea that RefinedThis types take levels.
odersky Jan 10, 2015
1d8c014
Rename RefinedThis -> SkolemType
odersky Jan 10, 2015
90c8ac3
Simplified condition in isSubType.
odersky Jan 10, 2015
9c53aaa
Adapted Skolemization to new handling of skolems.
odersky Jan 11, 2015
7df0423
Made constraint data structures pluggable.
odersky Jan 12, 2015
f76e81e
Streamline unification
odersky Jan 12, 2015
0b02ede
Added structural equals method to PolyParams
odersky Jan 13, 2015
1550492
Added alternative TrackingConstraint
odersky Jan 13, 2015
3e3ef52
Two new hooks in ConstraintHandling
odersky Jan 13, 2015
ef9c11f
Fix after review: reset state variable needsGc
odersky Jan 14, 2015
dec4617
New test: moduleSubtyping
odersky Jan 14, 2015
1a6cc68
Rename isConstrained -> canConstrain for clarity
odersky Jan 14, 2015
a24f73e
Removed redundant test in isSubType.
odersky Jan 14, 2015
c0b7509
Fixed bug/typo in comparing prefixes of ClassInfo types.
odersky Jan 14, 2015
1923483
Allow to merge TypeBounds and ClassInfos in |, &
odersky Jan 14, 2015
566dd6e
Fix skolemization logic.
odersky Jan 14, 2015
fbe4171
New constraint handling
odersky Jan 18, 2015
179a1bb
Removed check from addConstraint
odersky Jan 18, 2015
952aa7f
Avoid adding constraint under typeVarsMissContext is true
odersky Jan 18, 2015
23ae8d9
Dropped non-sensical transform in unify
odersky Jan 18, 2015
14f4c96
Removed checkBound tests
odersky Jan 18, 2015
9b260d0
Moved previously failing tests to pos
odersky Jan 18, 2015
5354f88
Fixed soundness hole in TypeComparer
odersky Jan 19, 2015
6771786
Compare ThisType refactoring
odersky Jan 19, 2015
50444f8
Refactor handling of NamedTypes in isSubType
odersky Jan 19, 2015
01f1a26
Refactorings in TypeComparer fourthTry
odersky Jan 19, 2015
68d58a6
Move PolyParam test later in isSubType and simplify addConstraint
odersky Jan 19, 2015
b9d018e
Make checkPropagated configurable
odersky Jan 19, 2015
963af8e
Streamline TypeComparer/ConstraintHandling interface.
odersky Jan 19, 2015
eed18aa
Small polishings for isSubType
odersky Jan 19, 2015
b45c69f
Plugging a possible hole in unify
odersky Jan 20, 2015
fd3a5be
New constraint method: narrowBound
odersky Jan 23, 2015
8061820
New constraint implementation: OrderingConstraint
odersky Jan 24, 2015
47238eb
Some finetunigs in TypeComparer.
odersky Jan 24, 2015
cdce02d
Fixes suggested by reviews from @smarter.
odersky Jan 24, 2015
2576193
Some small polishings in TypeComparer
odersky Jan 24, 2015
f0e60d3
Replace only substitutes top-level types.
odersky Jan 24, 2015
eb4d808
Added explanation to comment.
odersky Jan 24, 2015
a493791
Fixups taking into account reviewer's comments.
odersky Jan 27, 2015
350b121
Refinement of dependent parameter handling in OrderingConstraint
odersky Jan 28, 2015
37918e5
Cleanups prompted by reviews.
odersky Jan 28, 2015
70e55d2
Fixed problem with ensureSingleton
odersky Jan 28, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a proper solution or just a hack until #321 is properly fixed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe in this particular case it helps, but in minimized case it does not:

class ListDecorator[T >: Null <: AnyRef] {

  def mapconserve(f: T => Int): Int = {
    def loop(pending: T): Int = {
        val head1 = f(pending)
        loop(pending)
      }
    loop(null)
  }
}

Fails even if tailrec is in its own group.

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