diff options
author | odersky <odersky@gmail.com> | 2014-03-12 17:31:33 +0100 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2014-03-12 17:31:33 +0100 |
commit | db950e5e168f6fd71a367da343e352139e8d653e (patch) | |
tree | cc9e6b9d36bbd66c8454406cc9e28f5011ef2272 /src | |
parent | 6e7dd1b0e18bcdd767ea5625f03094bc41a049bd (diff) | |
parent | 66291018e0512b2d4e7d6bac017ab47b95939275 (diff) | |
download | dotty-db950e5e168f6fd71a367da343e352139e8d653e.tar.gz dotty-db950e5e168f6fd71a367da343e352139e8d653e.tar.bz2 dotty-db950e5e168f6fd71a367da343e352139e8d653e.zip |
Merge pull request #61 from odersky/fixes-t00xx
Fixes t00xx
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/Flags.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/core/SymDenotations.scala | 11 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 7 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 12 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 7 |
5 files changed, 29 insertions, 10 deletions
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala index d150bd6ab..8e17fb01d 100644 --- a/src/dotty/tools/dotc/core/Flags.scala +++ b/src/dotty/tools/dotc/core/Flags.scala @@ -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) diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala index b9eb2f945..bea8576c6 100644 --- a/src/dotty/tools/dotc/core/SymDenotations.scala +++ b/src/dotty/tools/dotc/core/SymDenotations.scala @@ -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) = { diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index ecf3eb9bc..39da1dbae 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -46,13 +46,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. */ override def checkStable(tp: Type, pos: Position)(implicit ctx: Context): Unit = diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index c24021936..2c5022726 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -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( @@ -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 diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 7bef0268e..c17c9d6d7 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -701,8 +701,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) } @@ -788,7 +789,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) |