aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2014-03-10 17:48:55 +0100
committerMartin Odersky <odersky@gmail.com>2014-03-10 17:48:55 +0100
commit7fa78597bf58a7759303095121a432cb258f447c (patch)
tree26dc6a9ed47235d50afb1d31d69693b153ae41ed /src/dotty/tools
parentba8d9ea2e4b887fc0faa1f636aade84c45292144 (diff)
downloaddotty-7fa78597bf58a7759303095121a432cb258f447c.tar.gz
dotty-7fa78597bf58a7759303095121a432cb258f447c.tar.bz2
dotty-7fa78597bf58a7759303095121a432cb258f447c.zip
Fix problems related to t0039
This test case exercised several problems: 1.)2.) Two ways to run into a cyclic references. Fixed by - assuming an early info when completing a typedef, similarly to what is done for a classdef - doing wellformed bounds checking in a later phase. Failure to check whether arguments correspond to F-bounds. - a substitution was missing.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/dotc/core/Flags.scala2
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala11
-rw-r--r--src/dotty/tools/dotc/typer/Checking.scala7
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala1
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala5
5 files changed, 18 insertions, 8 deletions
diff --git a/src/dotty/tools/dotc/core/Flags.scala b/src/dotty/tools/dotc/core/Flags.scala
index 0678b79be..620cd4fa5 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 5fbf6c2c4..bbe5cf986 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 25e6a7aa7..e3024b9a6 100644
--- a/src/dotty/tools/dotc/typer/Checking.scala
+++ b/src/dotty/tools/dotc/typer/Checking.scala
@@ -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
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index c24021936..9c8522b83 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -614,6 +614,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 6a1d279df..e195c2807 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -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)
+ if (false) // 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)
}