diff options
author | Martin Odersky <odersky@gmail.com> | 2016-01-31 14:03:26 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2016-02-09 09:43:05 +0100 |
commit | 9a6f82b2ecfd7462d0a1f4e0464878fd58231277 (patch) | |
tree | 8e9e46b08d7fdf45f4b1fd06b30d7e35c43f05b1 /src | |
parent | 44c14b3fb6e5eb6f2b9734f092eef1d85f6b4d18 (diff) | |
download | dotty-9a6f82b2ecfd7462d0a1f4e0464878fd58231277.tar.gz dotty-9a6f82b2ecfd7462d0a1f4e0464878fd58231277.tar.bz2 dotty-9a6f82b2ecfd7462d0a1f4e0464878fd58231277.zip |
Reorganize tests to account for new typing of projection
Tests with failed projections are moved to pos-scala2, which
was renamed from pos-special. Files in pos-scala2 are compiled
with -language:Scala2 option.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeOps.scala | 17 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 9 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Typer.scala | 16 |
3 files changed, 27 insertions, 15 deletions
diff --git a/src/dotty/tools/dotc/core/TypeOps.scala b/src/dotty/tools/dotc/core/TypeOps.scala index 26ce4ebf8..9fcc6abbc 100644 --- a/src/dotty/tools/dotc/core/TypeOps.scala +++ b/src/dotty/tools/dotc/core/TypeOps.scala @@ -435,7 +435,10 @@ trait TypeOps { this: Context => // TODO: Make standalone object. /** The realizability status of given type `tp`*/ def realizability(tp: Type): Realizability = tp.dealias match { case tp: TermRef => - if (tp.symbol.isRealizable) Realizable else NotStable + if (tp.symbol.isRealizable) Realizable + else if (!tp.symbol.isStable) NotStable + else if (!tp.symbol.isEffectivelyFinal) new NotFinal(tp.symbol) + else new ProblemInUnderlying(tp.info, realizability(tp.info)) case _: SingletonType | NoPrefix => Realizable case tp => @@ -684,10 +687,16 @@ object TypeOps { object Realizable extends Realizability("") - object NotConcrete extends Realizability("is not a concrete type") + object NotConcrete extends Realizability("it is not a concrete type") - object NotStable extends Realizability("is not a stable reference") + object NotStable extends Realizability("it is not a stable reference") + + class NotFinal(sym: Symbol)(implicit ctx: Context) + extends Realizability(i"it refers to nonfinal $sym") class HasProblemBounds(mbr: SingleDenotation)(implicit ctx: Context) - extends Realizability(i"has a member $mbr with possibly empty bounds ${mbr.info.bounds.lo} .. ${mbr.info.bounds.hi}") + extends Realizability(i"it has a member $mbr with possibly conflicting bounds ${mbr.info.bounds.lo} <: ... <: ${mbr.info.bounds.hi}") + + class ProblemInUnderlying(tp: Type, problem: Realizability)(implicit ctx: Context) + extends Realizability(i"its underlying type ${tp} ${problem.msg}") } diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index d333efa33..ee1c2a061 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -318,15 +318,14 @@ trait Checking { } /** Check that type `tp` is stable. */ - def checkStableAndRealizable(tp: Type, pos: Position)(implicit ctx: Context): Unit = + def checkStable(tp: Type, pos: Position)(implicit ctx: Context): Unit = if (!tp.isStable) ctx.error(d"$tp is not stable", pos) - else checkRealizable(tp, pos) /** Check that type `tp` is realizable. */ def checkRealizable(tp: Type, pos: Position)(implicit ctx: Context): Unit = { val rstatus = ctx.realizability(tp) if (rstatus ne TypeOps.Realizable) { - def msg = d"$tp is not a legal path since it ${rstatus.msg}" + def msg = d"$tp is not a legal path since ${rstatus.msg}" if (ctx.scala2Mode) ctx.migrationWarning(msg, pos) else ctx.error(msg, pos) } } @@ -339,7 +338,7 @@ trait Checking { def checkClassTypeWithStablePrefix(tp: Type, pos: Position, traitReq: Boolean)(implicit ctx: Context): Type = tp.underlyingClassRef(refinementOK = false) match { case tref: TypeRef => - if (ctx.phase <= ctx.refchecksPhase) checkStableAndRealizable(tref.prefix, pos) + if (ctx.phase <= ctx.refchecksPhase) checkStable(tref.prefix, pos) if (traitReq && !(tref.symbol is Trait)) ctx.error(d"$tref is not a trait", pos) tp case _ => @@ -442,7 +441,7 @@ trait NoChecking extends Checking { import tpd._ override def checkNonCyclic(sym: Symbol, info: TypeBounds, reportErrors: Boolean)(implicit ctx: Context): Type = info override def checkValue(tree: Tree, proto: Type)(implicit ctx: Context): tree.type = tree - override def checkStableAndRealizable(tp: Type, pos: Position)(implicit ctx: Context): Unit = () + override def checkStable(tp: Type, pos: Position)(implicit ctx: Context): Unit = () override def checkRealizable(tp: Type, pos: Position)(implicit ctx: Context): Unit = () override def checkClassTypeWithStablePrefix(tp: Type, pos: Position, traitReq: Boolean)(implicit ctx: Context): Type = tp override def checkImplicitParamsNotSingletons(vparamss: List[List[ValDef]])(implicit ctx: Context): Unit = () diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala index 79035108e..ce0a5c0f2 100644 --- a/src/dotty/tools/dotc/typer/Typer.scala +++ b/src/dotty/tools/dotc/typer/Typer.scala @@ -308,7 +308,10 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedSelect(tree: untpd.Select, pt: Type)(implicit ctx: Context): Tree = track("typedSelect") { def asSelect(implicit ctx: Context): Tree = { val qual1 = typedExpr(tree.qualifier, selectionProto(tree.name, pt, this)) - if (tree.name.isTypeName) checkStableAndRealizable(qual1.tpe, qual1.pos) + if (tree.name.isTypeName) { + checkStable(qual1.tpe, qual1.pos) + checkRealizable(qual1.tpe, qual1.pos) + } typedSelect(tree, pt, qual1) } @@ -342,7 +345,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedSelectFromTypeTree(tree: untpd.SelectFromTypeTree, pt: Type)(implicit ctx: Context): Tree = track("typedSelectFromTypeTree") { val qual1 = typedType(tree.qualifier, selectionProto(tree.name, pt, this)) - //checkRealizable(qual1.tpe, qual1.pos) + checkRealizable(qual1.tpe, qual1.pos) assignType(cpy.SelectFromTypeTree(tree)(qual1, tree.name), qual1) } @@ -823,7 +826,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedSingletonTypeTree(tree: untpd.SingletonTypeTree)(implicit ctx: Context): SingletonTypeTree = track("typedSingletonTypeTree") { val ref1 = typedExpr(tree.ref) - checkStableAndRealizable(ref1.tpe, tree.pos) + checkStable(ref1.tpe, tree.pos) + checkRealizable(ref1.tpe, tree.pos) assignType(cpy.SingletonTypeTree(tree)(ref1), ref1) } @@ -920,8 +924,8 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def completeAnnotations(mdef: untpd.MemberDef, sym: Symbol)(implicit ctx: Context): Unit = { // necessary to force annotation trees to be computed. sym.annotations.foreach(_.tree) - // necessary in order to mark the typed ahead annotations as definitiely typed: - untpd.modsDeco(mdef).mods.annotations.mapconserve(typedAnnotation) + // necessary in order to mark the typed ahead annotations as definitely typed: + untpd.modsDeco(mdef).mods.annotations.foreach(typedAnnotation) } def typedAnnotation(annot: untpd.Tree)(implicit ctx: Context): Tree = track("typedAnnotation") { @@ -1057,7 +1061,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit def typedImport(imp: untpd.Import, sym: Symbol)(implicit ctx: Context): Import = track("typedImport") { val expr1 = typedExpr(imp.expr, AnySelectionProto) - checkStableAndRealizable(expr1.tpe, imp.expr.pos) + checkStable(expr1.tpe, imp.expr.pos) assignType(cpy.Import(imp)(expr1, imp.selectors), sym) } |