Skip to content

Commit efe1bf2

Browse files
committed
Fix path error disgnastics
Fix wording so that it works for nested errors as well. Incorparte Tiark's latest example.
1 parent 6f6f5f9 commit efe1bf2

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

src/dotty/tools/dotc/core/TypeOps.scala

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,6 @@ trait TypeOps { this: Context => // TODO: Make standalone object.
633633
if (scala2Mode) migrationWarning(msg, pos)
634634
scala2Mode
635635
}
636-
637636
}
638637

639638
object TypeOps {
@@ -646,16 +645,16 @@ object TypeOps {
646645

647646
object Realizable extends Realizability("")
648647

649-
object NotConcrete extends Realizability("it is not a concrete type")
648+
object NotConcrete extends Realizability(" is not a concrete type")
650649

651-
object NotStable extends Realizability("it is not a stable reference")
650+
object NotStable extends Realizability(" is not a stable reference")
652651

653652
class NotFinal(sym: Symbol)(implicit ctx: Context)
654-
extends Realizability(i"it refers to nonfinal $sym")
653+
extends Realizability(i" refers to nonfinal $sym")
655654

656655
class HasProblemBounds(mbr: SingleDenotation)(implicit ctx: Context)
657-
extends Realizability(i"it has a member $mbr with possibly conflicting bounds ${mbr.info.bounds.lo} <: ... <: ${mbr.info.bounds.hi}")
656+
extends Realizability(i" has a member $mbr with possibly conflicting bounds ${mbr.info.bounds.lo} <: ... <: ${mbr.info.bounds.hi}")
658657

659658
class ProblemInUnderlying(tp: Type, problem: Realizability)(implicit ctx: Context)
660-
extends Realizability(i"its underlying type ${tp} ${problem.msg}")
659+
extends Realizability(i"s underlying type ${tp}${problem.msg}")
661660
}

src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ trait Checking {
325325
def checkRealizable(tp: Type, pos: Position)(implicit ctx: Context): Unit = {
326326
val rstatus = ctx.realizability(tp)
327327
if (rstatus ne TypeOps.Realizable) {
328-
def msg = d"$tp is not a legal path since ${rstatus.msg}"
328+
def msg = d"$tp is not a legal path since it${rstatus.msg}"
329329
if (ctx.scala2Mode) ctx.migrationWarning(msg, pos) else ctx.error(msg, pos)
330330
}
331331
}

test/dotc/tests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ class tests extends CompilerTest {
156156
@Test def neg_i705 = compileFile(negDir, "i705-inner-value-class", xerrors = 7)
157157
@Test def neg_i866 = compileFile(negDir, "i866", xerrors = 2)
158158
@Test def neg_i974 = compileFile(negDir, "i974", xerrors = 2)
159-
@Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 5)
159+
@Test def neg_i1050 = compileFile(negDir, "i1050", xerrors = 6)
160160
@Test def neg_i1050a = compileFile(negDir, "i1050a", xerrors = 2)
161161
@Test def neg_moduleSubtyping = compileFile(negDir, "moduleSubtyping", xerrors = 4)
162162
@Test def neg_escapingRefs = compileFile(negDir, "escapingRefs", xerrors = 2)

tests/neg/i1050.scala

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,22 @@ object Tiark2 {
6363
val v = new V {}
6464
v.brand("boom!"): Nothing
6565
}
66+
object Tiark3 {
67+
trait A { type L <: Nothing }
68+
trait B { type L >: Any}
69+
trait U {
70+
type X <: B
71+
def p2: X
72+
final lazy val p: X = p2
73+
def brand(x: Any): p.L = x
74+
}
75+
trait V extends U {
76+
type X = B with A
77+
def p2: X = ???
78+
}
79+
val v = new V {}
80+
v.brand("boom!"): Nothing
81+
}
6682
/*
6783
object Import {
6884
trait A { type L <: Nothing }

0 commit comments

Comments
 (0)