Skip to content

Fixes t00xx #61

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

Merged
merged 3 commits into from
Mar 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ object Flags {
final val ExpandedTypeParam = allOf(ExpandedName, TypeParam)

/** A parameter or parameter accessor */
final val ParamOrAccessor = Param | Accessor
final val ParamOrAccessor = Param | ParamAccessor

/** A covariant type parameter instance */
final val LocalCovariant = allOf(Local, Covariant)
Expand Down
11 changes: 8 additions & 3 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,14 @@ object SymDenotations {
if (myFlags is Touched) throw new CyclicReference(this)
myFlags |= Touched

completions.println(s"completing ${this.debugString}")
completer.complete(this)
completions.println(s"completed ${this.debugString}")
// completions.println(s"completing ${this.debugString}")
try completer.complete(this)
catch {
case ex: CyclicReference =>
completions.println(s"error while completing ${this.debugString}")
throw ex
}
// completions.println(s"completed ${this.debugString}")
}

protected[dotc] final def info_=(tp: Type) = {
Expand Down
7 changes: 5 additions & 2 deletions src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,16 @@ trait Checking extends NoChecking {
}

/** Check that type arguments `args` conform to corresponding bounds in `poly` */
override def checkBounds(args: List[tpd.Tree], poly: PolyType, pos: Position)(implicit ctx: Context): Unit =
override def checkBounds(args: List[tpd.Tree], poly: PolyType, pos: Position)(implicit ctx: Context): Unit = {
val argTypes = args.tpes
def substituted(tp: Type) = tp.substParams(poly, argTypes)
for ((arg, bounds) <- args zip poly.paramBounds) {
def notConforms(which: String, bound: Type) =
ctx.error(i"Type argument ${arg.tpe} does not conform to $which bound $bound", arg.pos)
if (!(arg.tpe <:< bounds.hi)) notConforms("upper", bounds.hi)
if (!(arg.tpe <:< substituted(bounds.hi))) notConforms("upper", bounds.hi)
if (!(bounds.lo <:< arg.tpe)) notConforms("lower", bounds.lo)
}
}

/** Check that type `tp` is stable.
* @return The type itself
Expand Down
12 changes: 11 additions & 1 deletion src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,18 @@ class Namer { typer: Typer =>
checkNoConflict(name)
val deferred = if (lacksDefinition(tree)) Deferred else EmptyFlags
val method = if (tree.isInstanceOf[DefDef]) Method else EmptyFlags

// to complete a constructor, move one context further out -- this
// is the context enclosing the class. Note that the context in which a
// constructor is recorded and the context in which it is completed are
// different: The former must have the class as owner (because the
// constructor is owned by the class), the latter must not (because
// constructor parameters are interpreted as if they are outside the class).
val cctx = if (tree.name == nme.CONSTRUCTOR) ctx.outer else ctx

record(ctx.newSymbol(
ctx.owner, name, tree.mods.flags | deferred | method,
adjustIfModule(new Completer(tree), tree),
adjustIfModule(new Completer(tree)(cctx), tree),
privateWithinClass(tree.mods), tree.pos))
case tree: Import =>
record(ctx.newSymbol(
Expand Down Expand Up @@ -614,6 +623,7 @@ class Namer { typer: Typer =>

def typeDefSig(tdef: TypeDef, sym: Symbol)(implicit ctx: Context): Type = {
completeParams(tdef.tparams)
sym.info = TypeBounds.empty // avoid cyclic reference errors for F-bounds
val tparamSyms = tdef.tparams map symbolOfTree
val rhsType = typedAheadType(tdef.rhs).tpe

Expand Down
7 changes: 4 additions & 3 deletions src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -699,8 +699,9 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val TypeBoundsTree(lo, hi) = desugar.typeBoundsTree(tree)
val lo1 = typed(lo)
val hi1 = typed(hi)
if (!(lo1.tpe <:< hi1.tpe))
ctx.error(i"lower bound ${lo1.tpe} does not conform to upper bound ${hi1.tpe}", tree.pos)
// need to do in later phase, as this might cause a cyclic reference error. See pos/t0039.scala
// if (!(lo1.tpe <:< hi1.tpe))
// ctx.error(i"lower bound ${lo1.tpe} does not conform to upper bound ${hi1.tpe}", tree.pos)
assignType(cpy.TypeBoundsTree(tree, lo1, hi1), lo1, hi1)
}

Expand Down Expand Up @@ -786,7 +787,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val constr1 = typed(constr).asInstanceOf[DefDef]
val parents1 = ensureConstrCall(ensureFirstIsClass(
parents mapconserve typedParent, cdef.pos.toSynthetic))
val self1 = typed(self).asInstanceOf[ValDef]
val self1 = typed(self)(ctx.outer).asInstanceOf[ValDef] // outer context where class memebers are not visible
val localDummy = ctx.newLocalDummy(cls, impl.pos)
val body1 = typedStats(body, localDummy)(inClassContext(self1.symbol))
checkNoDoubleDefs(cls)
Expand Down
6 changes: 6 additions & 0 deletions tests/new/t0039.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
abstract class Extensible[A, This <: Extensible[A, This]](x: A, xs: This) { self: This =>
def mkObj(x: A, xs: This): This;
}
class Fixed[A](x: A, xs: Fixed[A]) extends Extensible[A, Fixed[A]](x, xs) {
def mkObj(x: A, xs: Fixed[A]) = new Fixed(x, xs);
}
6 changes: 6 additions & 0 deletions tests/pos/t0002.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
object main {
def main(args: Array[String]) = {
val b = true;
while (b == true) { }
}
}
4 changes: 4 additions & 0 deletions tests/pos/t0054.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
class A {
case class B(x: C) extends A { val z: A.this.C = x }
class C {}
}