Skip to content

Commit

Permalink
Fix path error disgnastics
Browse files Browse the repository at this point in the history
Fix wording so that it works for nested errors as well.
Incorparte Tiark's latest example.
  • Loading branch information
odersky committed Jan 31, 2016
1 parent 6f6f5f9 commit efe1bf2
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
11 changes: 5 additions & 6 deletions src/dotty/tools/dotc/core/TypeOps.scala
Expand Up @@ -633,7 +633,6 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
if (scala2Mode) migrationWarning(msg, pos)
scala2Mode
}

}

object TypeOps {
Expand All @@ -646,16 +645,16 @@ object TypeOps {

object Realizable extends Realizability("")

object NotConcrete extends Realizability("it is not a concrete type")
object NotConcrete extends Realizability(" is not a concrete type")

object NotStable extends Realizability("it is not a stable reference")
object NotStable extends Realizability(" is not a stable reference")

class NotFinal(sym: Symbol)(implicit ctx: Context)
extends Realizability(i"it refers to nonfinal $sym")
extends Realizability(i" refers to nonfinal $sym")

class HasProblemBounds(mbr: SingleDenotation)(implicit ctx: Context)
extends Realizability(i"it has a member $mbr with possibly conflicting bounds ${mbr.info.bounds.lo} <: ... <: ${mbr.info.bounds.hi}")
extends Realizability(i" 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}")
extends Realizability(i"s underlying type ${tp}${problem.msg}")
}
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/typer/Checking.scala
Expand Up @@ -325,7 +325,7 @@ trait Checking {
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 ${rstatus.msg}"
def msg = d"$tp is not a legal path since it${rstatus.msg}"
if (ctx.scala2Mode) ctx.migrationWarning(msg, pos) else ctx.error(msg, pos)
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/dotc/tests.scala
Expand Up @@ -156,7 +156,7 @@ class tests extends CompilerTest {
@Test def neg_i705 = compileFile(negDir, "i705-inner-value-class", xerrors = 7)
@Test def neg_i866 = compileFile(negDir, "i866", xerrors = 2)
@Test def neg_i974 = compileFile(negDir, "i974", xerrors = 2)
@Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 5)
@Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 6)
@Test def neg_i1050a = compileFile(negDir, "i1050a", xerrors = 2)
@Test def neg_moduleSubtyping = compileFile(negDir, "moduleSubtyping", xerrors = 4)
@Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2)
Expand Down
16 changes: 16 additions & 0 deletions tests/neg/i1050.scala
Expand Up @@ -63,6 +63,22 @@ object Tiark2 {
val v = new V {}
v.brand("boom!"): Nothing
}
object Tiark3 {
trait A { type L <: Nothing }
trait B { type L >: Any}
trait U {
type X <: B
def p2: X
final lazy val p: X = p2
def brand(x: Any): p.L = x
}
trait V extends U {
type X = B with A
def p2: X = ???
}
val v = new V {}
v.brand("boom!"): Nothing
}
/*
object Import {
trait A { type L <: Nothing }
Expand Down

0 comments on commit efe1bf2

Please sign in to comment.