-
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.
Fail more eagerly when trying to adapt named unapply patterns (#22315)
closes #22192
- Loading branch information
Showing
6 changed files
with
102 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
-- Error: tests/neg/i22192.scala:6:12 ---------------------------------------------------------------------------------- | ||
6 | case City(iam = n, confused = p) => // error // error | ||
| ^^^^^^^ | ||
| No element named `iam` is defined in selector type City | ||
-- Error: tests/neg/i22192.scala:6:21 ---------------------------------------------------------------------------------- | ||
6 | case City(iam = n, confused = p) => // error // error | ||
| ^^^^^^^^^^^^ | ||
| No element named `confused` is defined in selector type City | ||
-- [E006] Not Found Error: tests/neg/i22192.scala:7:7 ------------------------------------------------------------------ | ||
7 | s"$n has a population of $p" // error // error | ||
| ^ | ||
| Not found: n | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E006] Not Found Error: tests/neg/i22192.scala:7:30 ----------------------------------------------------------------- | ||
7 | s"$n has a population of $p" // error // error | ||
| ^ | ||
| Not found: p | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg/i22192.scala:10:12 --------------------------------------------------------------------------------- | ||
10 | case Some(iam = n) => // error | ||
| ^^^^^^^ | ||
| No element named `iam` is defined in selector type City | ||
-- [E006] Not Found Error: tests/neg/i22192.scala:11:4 ----------------------------------------------------------------- | ||
11 | n // error | ||
| ^ | ||
| Not found: n | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,11 @@ | ||
import scala.language.experimental.namedTuples | ||
|
||
case class City(name: String, population: Int) | ||
|
||
def getCityInfo(city: City) = city match | ||
case City(iam = n, confused = p) => // error // error | ||
s"$n has a population of $p" // error // error | ||
|
||
def getCityInfo1(city: Option[City]) = city match | ||
case Some(iam = n) => // error | ||
n // 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,20 @@ | ||
-- Error: tests/neg/i22192a.scala:6:12 --------------------------------------------------------------------------------- | ||
6 | case Some(iam = n) => // error | ||
| ^^^^^^^ | ||
| No element named `iam` is defined in selector type (name : String) | ||
-- [E006] Not Found Error: tests/neg/i22192a.scala:7:4 ----------------------------------------------------------------- | ||
7 | n // error | ||
| ^ | ||
| Not found: n | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- Error: tests/neg/i22192a.scala:11:12 -------------------------------------------------------------------------------- | ||
11 | case Some(iam = n) => // error | ||
| ^^^^^^^ | ||
| No element named `iam` is defined in selector type (name : String, population : Int) | ||
-- [E006] Not Found Error: tests/neg/i22192a.scala:12:4 ---------------------------------------------------------------- | ||
12 | n // error | ||
| ^ | ||
| Not found: n | ||
| | ||
| longer explanation available when compiling with `-explain` |
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,13 @@ | ||
import scala.language.experimental.namedTuples | ||
|
||
type City = (name: String) | ||
|
||
def getCityInfo(city: Option[City]) = city match | ||
case Some(iam = n) => // error | ||
n // error | ||
case _ => | ||
|
||
def getCiryInfo1(city: Option[(name: String, population: Int)]) = city match | ||
case Some(iam = n) => // error | ||
n // error | ||
case _ => |
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,15 @@ | ||
import scala.language.experimental.namedTuples | ||
|
||
case class City(name: String, population: Int) | ||
|
||
def getCityInfo(city: City) = city match | ||
case City(population = p, name = n) => | ||
s"$n has a population of $p" | ||
|
||
def getCityInfo1(city: Option[(name: String)]) = city match | ||
case Some(name = n) => n | ||
case _ => | ||
|
||
def getCityInfo2(city: Option[(name: String, population: Int)]) = city match | ||
case Some(name = n) => n | ||
case _ => |