Skip to content

Commit ff65a2b

Browse files
committed
Fix test and error reporting
1 parent 1e4b2a1 commit ff65a2b

File tree

2 files changed

+2
-25
lines changed

2 files changed

+2
-25
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2323,7 +2323,7 @@ object Parsers {
23232323
val templ = templateClauseOpt(constr, bodyRequired = true)
23242324
def checkDef(tree: Tree) = tree match {
23252325
case _: DefDef | EmptyValDef => // ok
2326-
case _ => syntaxError("`def` expected", tree.pos.startPos)
2326+
case _ => syntaxError("`def` expected", tree.pos.startPos.orElse(templ.pos.startPos))
23272327
}
23282328
checkDef(templ.self)
23292329
templ.body.foreach(checkDef)

tests/neg/extensions.scala

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object extensions {
2828
def area = this.radius * this.radius * math.Pi
2929
}
3030

31-
extend Circle2 extends HasArea {} // error: `implements` or `{` expected
31+
extend Circle2 extends HasArea {} // error: `implements` or `{` expected // error: `def` expected
3232

3333
extend Circle implements HasAreaClass {
3434
def area = this.radius * this.radius * math.Pi
@@ -69,31 +69,8 @@ object extensions {
6969
extend (type T) {
7070
def ~[U](that: U): (T, U) = (this, that)
7171
}
72-
73-
// Conditional generic extensions
74-
75-
trait HasEql[T] {
76-
def === (that: T): Boolean
77-
}
78-
79-
extend (type T: Eql) implements HasEql[T] {
80-
def === (that: T): Boolean = implicitly[Eql[T]].eql(this, that)
81-
}
82-
83-
extend Rectangle[type T: Eql] implements HasEql[Rectangle[T]] {
84-
def === (that: Rectangle[T]) =
85-
this.x === that.x &&
86-
this.y === that.y &&
87-
this.width == that.width &&
88-
this.height == that.height
89-
}
90-
91-
extend List[List[type U]] {
92-
def flattened: List[U] = (this :\ (Nil: List[U]))(_ ++ _)
93-
}
9472
}
9573

96-
9774
object extensions1 {
9875
extend List[List[type T]] {
9976
def flattened: List[T] = (this :\ (Nil: List[T]))(_ ++ _)

0 commit comments

Comments
 (0)