Skip to content

Commit

Permalink
Backport "fix(#18265): crash on extension method without type nor RHS…
Browse files Browse the repository at this point in the history
…" to LTS (#20876)

Backports #18743 to the LTS branch.

PR submitted by the release tooling.
[skip ci]
  • Loading branch information
WojciechMazur authored Jul 1, 2024
2 parents 5647505 + 45faafb commit c4b5824
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 3 deletions.
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2607,6 +2607,8 @@ object Parsers {
parents match {
case parent :: Nil if !in.isNestedStart =>
reposition(if (parent.isType) ensureApplied(wrapNew(parent)) else parent)
case tkn if in.token == INDENT =>
New(templateBodyOpt(emptyConstructor, parents, Nil))
case _ =>
New(reposition(templateBodyOpt(emptyConstructor, parents, Nil)))
}
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i18265.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-- [E019] Syntax Error: tests/neg/i18265.scala:5:13 --------------------------------------------------------------------
5 | def twice // error
| ^
| Missing return type
|
| longer explanation available when compiling with `-explain`
5 changes: 5 additions & 0 deletions tests/neg/i18265.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trait Foo

val foo = new Foo:
extension (s: String)
def twice // error
4 changes: 2 additions & 2 deletions tests/semanticdb/expect/StructuralTypes.expect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ object StructuralTypes/*<-example::StructuralTypes.*/:

val V/*<-example::StructuralTypes.V.*/: Object/*->java::lang::Object#*/ {
def scalameta/*<-local4*/: String/*->scala::Predef.String#*/
} = /*<-local6*/new:
def scalameta/*<-local5*/ = "4.0"
} = new:
/*<-local6*/def scalameta/*<-local5*/ = "4.0"
V/*->example::StructuralTypes.V.*/.scalameta/*->scala::reflect::Selectable#selectDynamic().*/
end StructuralTypes/*->example::StructuralTypes.*/
2 changes: 1 addition & 1 deletion tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -3472,7 +3472,7 @@ Occurrences:
[16:9..16:15): Object -> java/lang/Object#
[17:8..17:17): scalameta <- local4
[17:19..17:25): String -> scala/Predef.String#
[18:6..18:6): <- local6
[19:4..19:4): <- local6
[19:8..19:17): scalameta <- local5
[20:2..20:3): V -> example/StructuralTypes.V.
[20:4..20:13): scalameta -> scala/reflect/Selectable#selectDynamic().
Expand Down

0 comments on commit c4b5824

Please sign in to comment.