diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index ff5e95f3aa03..aa6bf52c08a7 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1353,15 +1353,7 @@ object Parsers { def argumentStart(): Unit = colonAtEOLOpt() - if migrateTo3 && in.token == NEWLINE && in.next.token == LBRACE then - in.nextToken() - if in.indentWidth(in.offset) == in.currentRegion.indentWidth then - report.errorOrMigrationWarning( - em"""This opening brace will start a new statement in Scala 3. - |It needs to be indented to the right to keep being treated as - |an argument to the previous expression.${rewriteNotice()}""", - in.sourcePos(), from = `3.0`) - patch(source, Span(in.offset), " ") + newLineOptWhenFollowedBy(LBRACE) def possibleTemplateStart(isNew: Boolean = false): Unit = in.observeColonEOL(inTemplate = true) diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index b3d824a2efd2..ca68d9041a81 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -569,9 +569,9 @@ object Scanners { * - In Scala 2: Only `{` is treated as continuing, irrespective of indentation. * But this is in fact handled by Parser.argumentStart which skips a NEWLINE, * so we always assume false here. - * - In Scala 3: Only indented statements are treated as continuing, as long as + * - In Scala 3: Indented statements are treated as continuing, as long as * they start with `(`, `[` or `{`, or the last statement ends in a `return`. - * The Scala 2 rules apply under source `3.0-migration` or under `-no-indent`. + * The Scala 2 rules apply under source `3.0-migration` or under `-no-indent`. */ inline def isContinuing = lastWidth < nextWidth diff --git a/compiler/src/dotty/tools/dotc/reporting/trace.scala b/compiler/src/dotty/tools/dotc/reporting/trace.scala index 8e8d3efb8b40..e4d552886648 100644 --- a/compiler/src/dotty/tools/dotc/reporting/trace.scala +++ b/compiler/src/dotty/tools/dotc/reporting/trace.scala @@ -55,7 +55,7 @@ trait TraceSyntax: apply(question, printer, { val showOp: T => String = inline if show == true then val showT = summonInline[Show[T]] - { + locally { given Show[T] = showT t => i"$t" } diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 3c4146f7ca2d..6b3c9a74f554 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -3555,7 +3555,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer else errorTree(tree, em"Missing arguments for $methodStr") case _ => tryInsertApplyOrImplicit(tree, pt, locked) { - errorTree(tree, MethodDoesNotTakeParameters(tree)) + errorTree(tree, MethodDoesNotTakeParameters(tree), tree.srcPos.endPos) } } diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala index b8b38cce92e4..e9207b5745c6 100644 --- a/compiler/test/dotty/tools/dotc/CompilationTests.scala +++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala @@ -149,7 +149,6 @@ class CompilationTests { compileFile("tests/neg-custom-args/i3246.scala", scala2CompatMode), compileFile("tests/neg-custom-args/overrideClass.scala", scala2CompatMode), compileFile("tests/neg-custom-args/ovlazy.scala", scala2CompatMode.and("-Xfatal-warnings")), - compileFile("tests/neg-custom-args/newline-braces.scala", scala2CompatMode.and("-Xfatal-warnings")), compileFile("tests/neg-custom-args/autoTuplingTest.scala", defaultOptions.andLanguageFeature("noAutoTupling")), compileFile("tests/neg-custom-args/i1650.scala", allowDeepSubtypes), compileFile("tests/neg-custom-args/i3882.scala", allowDeepSubtypes), diff --git a/tests/neg-custom-args/newline-braces.scala b/tests/neg-custom-args/newline-braces.scala deleted file mode 100644 index 0a5e2a469bf3..000000000000 --- a/tests/neg-custom-args/newline-braces.scala +++ /dev/null @@ -1,6 +0,0 @@ -def f: List[Int] = { - List(1, 2, 3).map // no newline inserted here in Scala-2 compat mode - { x => // error (migration) - x + 1 - } -} diff --git a/tests/neg/bad-unapplies.check b/tests/neg/bad-unapplies.check index 44633ca6950a..1a5a3e58499d 100644 --- a/tests/neg/bad-unapplies.check +++ b/tests/neg/bad-unapplies.check @@ -19,10 +19,10 @@ | D cannot be used as an extractor in a pattern because it lacks an unapply or unapplySeq method | | longer explanation available when compiling with `-explain` --- [E050] Type Error: tests/neg/bad-unapplies.scala:25:9 --------------------------------------------------------------- +-- [E050] Type Error: tests/neg/bad-unapplies.scala:25:10 -------------------------------------------------------------- 25 | case E("2") => // error (value unapply in object E does not take parameters) - | ^ - | value unapply in object E does not take parameters + | ^ + | value unapply in object E does not take parameters | | longer explanation available when compiling with `-explain` -- [E107] Syntax Error: tests/neg/bad-unapplies.scala:26:10 ------------------------------------------------------------ diff --git a/tests/neg/i10857.check b/tests/neg/i10857.check new file mode 100644 index 000000000000..1ffec45a3997 --- /dev/null +++ b/tests/neg/i10857.check @@ -0,0 +1,31 @@ +-- [E008] Not Found Error: tests/neg/i10857.scala:33:17 ---------------------------------------------------------------- +33 | println(Module.valueOf("Red")) // error: value valueOf is not a member + | ^^^^^^^^^^^^^^ + | value valueOf is not a member of object Module +-- [E008] Not Found Error: tests/neg/i10857.scala:36:21 ---------------------------------------------------------------- +36 | println(new Module.GivenBar()) // error: type GivenBar is not a member + | ^^^^^^^^^^^^^^^ + | type GivenBar is not a member of object Module - did you mean Module.Givens.type? +-- [E050] Type Error: tests/neg/i10857.scala:37:25 --------------------------------------------------------------------- +37 | println(Module.GivenBar(23)) // error: method GivenBar does not take parameters + | ^ + | given instance GivenBar in object Module does not take parameters + | + | longer explanation available when compiling with `-explain` +-- [E007] Type Mismatch Error: tests/neg/i10857.scala:41:24 ------------------------------------------------------------ +41 | println(Module.Member("?")(23)) // error: Found: ("?" : String) Required: Int // error: method Member in object Module does not take more parameters + | ^^^ + | Found: ("?" : String) + | Required: Int + | + | longer explanation available when compiling with `-explain` +-- [E050] Type Error: tests/neg/i10857.scala:41:28 --------------------------------------------------------------------- +41 | println(Module.Member("?")(23)) // error: Found: ("?" : String) Required: Int // error: method Member in object Module does not take more parameters + | ^ + | method Member in object Module does not take more parameters + | + | longer explanation available when compiling with `-explain` +-- [E172] Type Error: tests/neg/i10857.scala:42:28 --------------------------------------------------------------------- +42 | println(summon[Module.Baz]) // error: no implicit argument of type Module.Baz was found + | ^ + | No given instance of type Module.Baz was found for parameter x of method summon in object Predef diff --git a/tests/neg/i10857.scala b/tests/neg/i10857.scala index b9128933484f..ba3dcb250285 100644 --- a/tests/neg/i10857.scala +++ b/tests/neg/i10857.scala @@ -38,7 +38,7 @@ object Module: println(new Module.Member()) println(Module.Member(23)) - println(Module.Member("?")(23)) // error: Found: ("?" : String) Required: Int + println(Module.Member("?")(23)) // error: Found: ("?" : String) Required: Int // error: method Member in object Module does not take more parameters println(summon[Module.Baz]) // error: no implicit argument of type Module.Baz was found println(summon[Module.Qux]) diff --git a/tests/neg/i12554a.scala b/tests/neg/i12554a.scala index 3ec6725d5fa4..662acb6effc7 100644 --- a/tests/neg/i12554a.scala +++ b/tests/neg/i12554a.scala @@ -17,7 +17,7 @@ object Test { def i: Unit = { f("Foo") - {} // ok, error in Scala 2 + {} // error, error in Scala 2 } def j: Int = { diff --git a/tests/neg/i14818.check b/tests/neg/i14818.check index 4f85ecbd13c4..936c8371df6e 100644 --- a/tests/neg/i14818.check +++ b/tests/neg/i14818.check @@ -3,10 +3,10 @@ | ^^^^^^ | no eligible member B at M | M.B cannot be exported because it clashes with another export in the same export clause --- [E050] Type Error: tests/neg/i14818.scala:16:10 --------------------------------------------------------------------- +-- [E050] Type Error: tests/neg/i14818.scala:16:11 --------------------------------------------------------------------- 16 | val x = b(1) // error - | ^ - | method b in object T3 does not take parameters + | ^ + | method b in object T3 does not take parameters | | longer explanation available when compiling with `-explain` -- Error: tests/neg/i14818.scala:19:22 --------------------------------------------------------------------------------- diff --git a/tests/neg/i1707.scala b/tests/neg/i1707.scala index ede2dc75d3c7..5263e233727a 100644 --- a/tests/neg/i1707.scala +++ b/tests/neg/i1707.scala @@ -17,6 +17,7 @@ object DepBug { import d.* a m (b) } + { import dep.* a m (b) // error: not found: a diff --git a/tests/neg/i9437.check b/tests/neg/i9437.check index 3bac99b07571..1d4da50cf823 100644 --- a/tests/neg/i9437.check +++ b/tests/neg/i9437.check @@ -1,6 +1,6 @@ --- [E050] Type Error: tests/neg/i9437.scala:7:10 ----------------------------------------------------------------------- +-- [E050] Type Error: tests/neg/i9437.scala:7:14 ----------------------------------------------------------------------- 7 | println(x.f1()) // error - | ^^^^ - | method selectDynamic in trait Selectable does not take parameters + | ^ + | method selectDynamic in trait Selectable does not take parameters | | longer explanation available when compiling with `-explain` diff --git a/tests/new/i16760.scala b/tests/new/i16760.scala new file mode 100644 index 000000000000..478f243f66cd --- /dev/null +++ b/tests/new/i16760.scala @@ -0,0 +1,13 @@ +object Test { + def main(args: Array[String]): Unit = { + def process(arg: Int)(block: => Unit): Int = arg + val x = process(1) + { + } + println(x) + val y = process(2) + ( () + ) + println(y) + } +} \ No newline at end of file diff --git a/tests/pos-with-compiler-cc/dotc/reporting/trace.scala b/tests/pos-with-compiler-cc/dotc/reporting/trace.scala index 528c8bd43502..451e198d1ea3 100644 --- a/tests/pos-with-compiler-cc/dotc/reporting/trace.scala +++ b/tests/pos-with-compiler-cc/dotc/reporting/trace.scala @@ -55,7 +55,7 @@ trait TraceSyntax: apply(question, printer, { val showOp: T => String = inline if show == true then val showT = summonInline[Show[T]] - { + locally { given Show[T] = showT t => i"$t" } diff --git a/tests/pos/indented-parens.scala b/tests/pos/indented-parens.scala index 33c0b9ca60b9..8e7366fd5024 100644 --- a/tests/pos/indented-parens.scala +++ b/tests/pos/indented-parens.scala @@ -7,5 +7,6 @@ def f(x: Int) (2) + f(1) {2} + { println(x) }