-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix varargs in methods #2135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix varargs in methods #2135
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM for the most part! Some minor nitpicks to fix and adding a test for constructors, then merge! 🎉
compiler/test/dotc/tests.scala
Outdated
@@ -153,6 +153,7 @@ class tests extends CompilerTest { | |||
@Test def pos_anonClassSubtyping = compileFile(posDir, "anonClassSubtyping", twice) | |||
@Test def pos_extmethods = compileFile(posDir, "extmethods", twice) | |||
@Test def pos_companions = compileFile(posDir, "companions", twice) | |||
@Test def posVarargsInMethodsT1625 = compileFiles(posDir + "varargsInMethodsT1625/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should also apply to constructors - I think your implementation supports this, I guess it's just the name that is misleading.
compiler/test/dotc/tests.scala
Outdated
@@ -177,6 +178,8 @@ class tests extends CompilerTest { | |||
@Test def neg_all = compileFiles(negDir, verbose = true, compileSubDirs = false) | |||
@Test def neg_typedIdents() = compileDir(negDir, "typedIdents") | |||
|
|||
@Test def negVarargsInMethodsT1625 = compileFiles(negDir + "varargsInMethodsT1625/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
|
||
case class VarArgsParamMustComeLast()(implicit ctx: Context) | ||
extends Message(IncorrectRepeatedParameterSyntaxID) { | ||
override def msg: String = "*-parameter must come last" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's say "varargs parameter must come last"
, mixing symbols and text like this feels kind of weird IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied error message from Scala Compiler :)
@@ -4,23 +4,24 @@ package parsing | |||
|
|||
import scala.collection.mutable.ListBuffer | |||
import scala.collection.immutable.BitSet | |||
import util.{ SourceFile, SourcePosition } | |||
import util.{SourceFile, SourcePosition} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also - these changes here - are they done by your editor or by you? I'd leave them out of the diff
import ast.Trees._ | ||
import Decorators._ | ||
import StdNames._ | ||
import util.Positions._ | ||
import Constants._ | ||
import ScriptParsers._ | ||
import Comments._ | ||
import scala.annotation.{tailrec, switch} | ||
|
||
import scala.annotation.{switch, tailrec} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same with this, if you intended to move this so that scala
imports are separate from internal imports, then this should be at the top with the other one. Otherwise let's get rid off this change.
@@ -0,0 +1,3 @@ | |||
trait T1 { | |||
def foo(x: String*, y: String): Int // error: *-parameter must come last |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also - just an FYI, the ": error text here" part of the comment is not parsed in any way (currently)
no need to change or anything
Fix case for constructor. Move `checkVarArgsRules` to `paramClauses`
Thanks @mielientiev! 🎉 |
@@ -177,6 +178,8 @@ class tests extends CompilerTest { | |||
@Test def neg_all = compileFiles(negDir, verbose = true, compileSubDirs = false) | |||
@Test def neg_typedIdents() = compileDir(negDir, "typedIdents") | |||
|
|||
@Test def negVarargsT1625 = compileFiles(negDir + "varargsInMethodsT1625/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an unnecessary complication, just put your test sources in tests/neg/
and remove this @Test def ...
. Also use the prefix i1625
for the test sources.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is going away once we merge #2125 anyway, I'll deal with it.
Fix for issue: #1625