-
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.
Merge pull request #15423 from dotty-staging/fix-11982
Refine Matchtype checking
- Loading branch information
Showing
16 changed files
with
356 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
-- [E007] Type Mismatch Error: tests/neg/6570-1.scala:23:27 ------------------------------------------------------------ | ||
23 | def thing = new Trait1 {} // error | ||
| ^ | ||
| Found: Object with Trait1 {...} | ||
| Required: N[Box[Int & String]] | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce N[Box[Int & String]] | ||
| failed since selector Box[Int & String] | ||
| is uninhabited (there are no values of that type). | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570-1.scala:36:54 ------------------------------------------------------------ | ||
36 | def foo[T <: Cov[Box[Int]]](c: Root[T]): Trait2 = c.thing // error | ||
| ^^^^^^^ | ||
| Found: M[T] | ||
| Required: Trait2 | ||
| | ||
| where: T is a type in method foo with bounds <: Cov[Box[Int]] | ||
| | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce M[T] | ||
| failed since selector T | ||
| does not uniquely determine parameter x in | ||
| case Cov[x] => N[x] | ||
| The computed bounds for the parameter are: | ||
| x >: Box[Int] | ||
| | ||
| 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
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/i11982.scala:22:38 --------------------------------------------------------------------------------- | ||
22 | val p1: ("msg", 42) = unpair[Tshape] // error: no singleton value for Any | ||
| ^ | ||
| No singleton value available for Any. |
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,27 @@ | ||
package tuplefun | ||
object Unpair { | ||
|
||
def pair[A, B](using a: ValueOf[A], b: ValueOf[B]): Tuple2[A, B] = | ||
(a.value, b.value) | ||
|
||
def unpair[X <: Tuple2[?, ?]]( | ||
using a: ValueOf[Tuple.Head[X]], | ||
b: ValueOf[Tuple.Head[Tuple.Tail[X]]] | ||
): Tuple2[Tuple.Head[X], Tuple.Head[Tuple.Tail[X]]] = | ||
type AA = Tuple.Head[X] | ||
type BB = Tuple.Head[Tuple.Tail[X]] | ||
pair[AA, BB](using a, b) | ||
} | ||
|
||
object UnpairApp { | ||
import Unpair._ | ||
|
||
type Tshape = ("msg", 42) | ||
|
||
// the following won't compile when in the same file as Unpair | ||
val p1: ("msg", 42) = unpair[Tshape] // error: no singleton value for Any | ||
|
||
@main def pairHello: Unit = | ||
assert(p1 == ("msg", 42)) | ||
println(p1) | ||
} |
Oops, something went wrong.