-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #5792 #6230
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
Closed
Closed
Fix #5792 #6230
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
object Test { | ||
def foo(a: Any) = a | ||
def foo(s: String*) = s | ||
foo("") // error | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
public class JavaClass { | ||
public static class Element { | ||
|
||
} | ||
|
||
public static <T extends Element> int foo(Element a, Class<T> b, boolean c, Class<? extends T>... d) { | ||
return 1; | ||
} | ||
|
||
public static <T extends Element> int foo(Element a, Class<? extends T> b, boolean c) { | ||
return 2; | ||
} | ||
|
||
public static <T extends Element> int foo(Element a, Class<? extends T>... b) { | ||
return 3; | ||
} | ||
|
||
public static <T extends Element> int foo(Element a, boolean b, Class<? extends T>... c) { | ||
return 4; | ||
} | ||
|
||
static { | ||
foo(new Element(), Element.class, false); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class Test { | ||
import JavaClass._ | ||
// in Scala2, this is not actually an error (see https://github.com/scala/bug/issues/4775) | ||
// overloading selection needs to decide between: | ||
// | ||
// def foo[T <: Element](a: Element, b: Class[T], c: Boolean, d: Class[_ <: T]*) | ||
// def foo[T <: Element](a: Element, b: Class[_ <: T], c: Boolean) | ||
// | ||
// The first is not as specific as the second, since it has more arguments. | ||
// The second _should_ be as specific as the first, | ||
// but the T parameter would need to capture the wildcard of b. | ||
// Since we don't allow wildcard capture anymore, | ||
// we cannot infer anything for T | ||
// and just say the second is not as specific as the first either. | ||
// | ||
// As a note to whomever will be revisiting this in the future, | ||
// we can select the same overload as Scala2 by selecting the one | ||
// without vararg parameter when neither is more specific. | ||
// The argument is that since one overload has varargs and the other doesn't, | ||
// the callsite must be trying to pass no varargs, | ||
// so we should select the overload that doesn't actually have any. | ||
// This breaks no tests, but potentially allows too much. | ||
foo(new Element, classOf[Element], false) // error | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class C { | ||
def foo(xs: Int*): Int = xs.toSeq.head | ||
def foo(x: Int): Int = x | ||
foo(2) | ||
|
||
def fooT[T](xs: T*): T = xs.toSeq.head | ||
def fooT[T](x: T): T = x | ||
fooT(2) | ||
|
||
def f[T](x: T): T = x | ||
def f[T](x: T, xs: T*): T = x | ||
|
||
f(5) | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.