-
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.
Do not use provablyEmpty anymore; use S <: T + provablyDisjoint(S, T)…
… instead. Fundamentally, the `provablyEmpty(scrut)` test was meant to prevent situations where both `scrut <: pattern` and `provablyDisjoint(scrut, pattern)` are true. That is a problem because it allows a match type to reduce in two different ways depending on the context. Instead, we basically use that combination of `scrut <: pattern` and `provablydisjoint(scrut, pattern)` as the *definition* for `provablyEmpty`. When both those conditions arise together, we refuse to reduce the match type. This allows one example to pass that did not pass before, but that particular example does not seem to cause unsoundness. In a sense, `provablyEmpty` was too strong here.
- Loading branch information
Showing
5 changed files
with
178 additions
and
71 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 was deleted.
Oops, something went wrong.
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,116 @@ | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:26:50 -------------------------------------------------------------- | ||
26 | def foo[T <: Cov[Int]](c: Child[T]): Trait2 = c.thing // error | ||
| ^^^^^^^ | ||
| Found: UpperBoundParametricVariant.M[T] | ||
| Required: Base.Trait2 | ||
| | ||
| where: T is a type in method foo with bounds <: UpperBoundParametricVariant.Cov[Int] | ||
| | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce UpperBoundParametricVariant.M[T] | ||
| failed since selector T | ||
| does not uniquely determine parameter x in | ||
| case UpperBoundParametricVariant.Cov[x] => Base.N[x] | ||
| The computed bounds for the parameter are: | ||
| x <: Int | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:29:29 -------------------------------------------------------------- | ||
29 | def thing = new Trait1 {} // error | ||
| ^ | ||
| Found: Object with Base.Trait1 {...} | ||
| Required: Base.N[String & Int] | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Base.N[String & Int] | ||
| failed since selector String & Int | ||
| is uninhabited (there are no values of that type). | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:47:32 -------------------------------------------------------------- | ||
47 | def foo(c: Child): Trait2 = c.thing // error | ||
| ^^^^^^^ | ||
| Found: InheritanceVariant.M[c.B] | ||
| Required: Base.Trait2 | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce InheritanceVariant.M[c.B] | ||
| failed since selector c.B | ||
| does not uniquely determine parameter a in | ||
| case InheritanceVariant.Trick[a] => Base.N[a] | ||
| The computed bounds for the parameter are: | ||
| a >: Int | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:51:29 -------------------------------------------------------------- | ||
51 | def thing = new Trait1 {} // error | ||
| ^ | ||
| Found: Object with Base.Trait1 {...} | ||
| Required: Base.N[String & Int] | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Base.N[String & Int] | ||
| failed since selector String & Int | ||
| is uninhabited (there are no values of that type). | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:69:29 -------------------------------------------------------------- | ||
69 | def thing = new Trait1 {} // error | ||
| ^ | ||
| Found: Object with Base.Trait1 {...} | ||
| Required: Base.N[String & Int] | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Base.N[String & Int] | ||
| failed since selector String & Int | ||
| is uninhabited (there are no values of that type). | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:86:29 -------------------------------------------------------------- | ||
86 | def thing = new Trait1 {} // error | ||
| ^ | ||
| Found: Object with Base.Trait1 {...} | ||
| Required: Base.N[String & Int] | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Base.N[String & Int] | ||
| failed since selector String & Int | ||
| is uninhabited (there are no values of that type). | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:103:32 ------------------------------------------------------------- | ||
103 | def foo(c: Child): Trait2 = c.thing // error | ||
| ^^^^^^^ | ||
| Found: UpperBoundVariant.M[c.A] | ||
| Required: Base.Trait2 | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce UpperBoundVariant.M[c.A] | ||
| failed since selector c.A | ||
| does not uniquely determine parameter t in | ||
| case UpperBoundVariant.Cov[t] => Base.N[t] | ||
| The computed bounds for the parameter are: | ||
| t <: Int | ||
| | ||
| longer explanation available when compiling with `-explain` | ||
-- [E007] Type Mismatch Error: tests/neg/6570.scala:107:29 ------------------------------------------------------------- | ||
107 | def thing = new Trait1 {} // error | ||
| ^ | ||
| Found: Object with Base.Trait1 {...} | ||
| Required: Base.N[String & Int] | ||
| | ||
| Note: a match type could not be fully reduced: | ||
| | ||
| trying to reduce Base.N[String & Int] | ||
| failed since selector String & Int | ||
| is uninhabited (there are no values of that type). | ||
| | ||
| 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
object Test { | ||
type FieldType2[K, +V] = V with KeyTag2[K, V] | ||
trait KeyTag2[K, +V] extends Any | ||
|
||
type WrapUpper = Tuple | ||
type Wrap[A] = Tuple1[A] | ||
|
||
type Extract[A <: WrapUpper] = A match { | ||
case Wrap[h] => h | ||
} | ||
|
||
summon[Extract[Wrap[FieldType2["foo", Int]]] =:= FieldType2["foo", Int]] | ||
|
||
// This used to cause an error because `Tuple1[FieldType2["foo", Int]]` was | ||
// "provablyEmpty". Since we switched to testing the combination of | ||
// `scrut <: pattern` *and* `provablyDisjoint(scrut, pattern)` instead, this | ||
// particular example compiles, because `FieldType2["foo", Int]` is not | ||
// `provablyDisjoint` from `h` (`Any`). | ||
} |