-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Check user defined PolyFunction refinements " to LTS (#20647)
Backports #18457 to the LTS branch. PR submitted by the release tooling. [skip ci]
- Loading branch information
Showing
19 changed files
with
137 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,4 @@ | ||
-- Error: tests/neg/i18302b.scala:3:32 --------------------------------------------------------------------------------- | ||
3 |def polyFun: PolyFunction { def apply(x: Int)(y: Int): Int } = // error | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|Implementation restriction: PolyFunction apply must have exactly one parameter list and optionally type arguments. No by-name nor varags are allowed. |
This file contains 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 @@ | ||
def test = polyFun(1)(2) | ||
|
||
def polyFun: PolyFunction { def apply(x: Int)(y: Int): Int } = // error | ||
new PolyFunction: | ||
def apply(x: Int)(y: Int): Int = x + y |
This file contains 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,4 @@ | ||
-- Error: tests/neg/i18302c.scala:4:32 --------------------------------------------------------------------------------- | ||
4 |def polyFun: PolyFunction { def foo(x: Int): Int } = // error | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
| PolyFunction only supports apply method refinements |
This file contains 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 @@ | ||
import scala.reflect.Selectable.reflectiveSelectable | ||
|
||
def test = polyFun.foo(1) | ||
def polyFun: PolyFunction { def foo(x: Int): Int } = // error | ||
new PolyFunction { def foo(x: Int): Int = x + 1 } |
This file contains 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,4 @@ | ||
-- Error: tests/neg/i18302d.scala:1:32 --------------------------------------------------------------------------------- | ||
1 |def polyFun: PolyFunction { def apply: Int } = // error | ||
| ^^^^^^^^^^^^^^ | ||
|Implementation restriction: PolyFunction apply must have exactly one parameter list and optionally type arguments. No by-name nor varags are allowed. |
This file contains 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,2 @@ | ||
def polyFun: PolyFunction { def apply: Int } = // error | ||
new PolyFunction { def apply: Int = 1 } |
This file contains 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,8 @@ | ||
-- Error: tests/neg/i18302e.scala:1:13 --------------------------------------------------------------------------------- | ||
1 |def polyFun: PolyFunction { } = // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| PolyFunction subtypes must refine the apply method | ||
-- Error: tests/neg/i18302e.scala:4:15 --------------------------------------------------------------------------------- | ||
4 |def polyFun(f: PolyFunction { }) = () // error | ||
| ^^^^^^^^^^^^^^^^^ | ||
| PolyFunction subtypes must refine the apply method |
This file contains 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,4 @@ | ||
def polyFun: PolyFunction { } = // error | ||
new PolyFunction { } | ||
|
||
def polyFun(f: PolyFunction { }) = () // error |
This file contains 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,12 @@ | ||
-- Error: tests/neg/i18302f.scala:1:13 --------------------------------------------------------------------------------- | ||
1 |def polyFun: PolyFunction = // error | ||
| ^^^^^^^^^^^^ | ||
| PolyFunction subtypes must refine the apply method | ||
-- Error: tests/neg/i18302f.scala:4:16 --------------------------------------------------------------------------------- | ||
4 |def polyFun2(a: PolyFunction) = () // error | ||
| ^^^^^^^^^^^^ | ||
| PolyFunction subtypes must refine the apply method | ||
-- Error: tests/neg/i18302f.scala:6:14 --------------------------------------------------------------------------------- | ||
6 |val polyFun3: PolyFunction = // error | ||
| ^^^^^^^^^^^^ | ||
| PolyFunction subtypes must refine the apply method |
This file contains 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,7 @@ | ||
def polyFun: PolyFunction = // error | ||
new PolyFunction { } | ||
|
||
def polyFun2(a: PolyFunction) = () // error | ||
|
||
val polyFun3: PolyFunction = // error | ||
new PolyFunction { } |
This file contains 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,6 @@ | ||
def polyFun1: Option[PolyFunction] = ??? // error | ||
def polyFun2: PolyFunction & Any = ??? // error | ||
def polyFun3: Any & PolyFunction = ??? // error | ||
def polyFun4: PolyFunction | Any = ??? // error | ||
def polyFun5: Any | PolyFunction = ??? // error | ||
def polyFun6(a: Any | PolyFunction) = ??? // error |
This file contains 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 @@ | ||
def polyFunByName: PolyFunction { def apply(thunk: => Int): Int } = // error | ||
new PolyFunction { def apply(thunk: => Int): Int = 1 } | ||
|
||
def polyFunVarArgs: PolyFunction { def apply(args: Int*): Int } = // error | ||
new PolyFunction { def apply(thunk: Int*): Int = 1 } |
This file contains 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,8 @@ | ||
package example | ||
|
||
object Main { | ||
def main(a: Array[String]): Unit = { | ||
val p: PolyFunction = // error: PolyFunction subtypes must refine the apply method | ||
[A] => (xs: List[A]) => xs.headOption | ||
} | ||
} |
This file contains 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,4 @@ | ||
def test = polyFun(1) | ||
|
||
def polyFun: PolyFunction { def apply(x: Int): Int } = | ||
new PolyFunction { def apply(x: Int): Int = x + 1 } |