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 #8545 from joroKr21/variance-holes
Plug many variance holes (pos and neg)
- Loading branch information
Showing
11 changed files
with
257 additions
and
63 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
t7872b.scala:8: error: contravariant type a occurs in covariant position in type [-a]List[a] of type l | ||
t7872b.scala:8: error: contravariant type a occurs in covariant position in type [-a]List[a] of value <local l> | ||
def oops1 = down[({type l[-a] = List[a]})#l](List('whatever: Object)).head + "oops" | ||
^ | ||
t7872b.scala:19: error: covariant type a occurs in contravariant position in type [+a]coinv.Stringer[a] of type l | ||
t7872b.scala:19: error: covariant type a occurs in contravariant position in type [+a]a => String of value <local l> | ||
def oops2 = up[({type l[+a] = Stringer[a]})#l]("printed: " + _) | ||
^ | ||
2 errors |
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 @@ | ||
t9911.scala:23: error: super may not be used on value source | ||
super.source.getSomething | ||
^ | ||
1 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,28 @@ | ||
// This should say: | ||
// Error: super may not be used on value source | ||
class ScalacBug { | ||
|
||
class SomeClass { | ||
|
||
type U | ||
|
||
// Changing T or U stops the problem | ||
def getSomething[T]: U = ??? | ||
} | ||
|
||
trait Base { | ||
|
||
// Changing this to a def like it should be stops the problem | ||
val source: SomeClass = ??? | ||
} | ||
|
||
class Bug extends Base { | ||
|
||
override val source = { | ||
// Not calling the function stops the problem | ||
super.source.getSomething | ||
??? | ||
} | ||
} | ||
|
||
} |
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,22 @@ | ||
variance-holes.scala:9: error: covariant type x occurs in contravariant position in type [+x, +y] >: F[x,y] of type F2 | ||
def asWiden[F2[+x, +y] >: F[x, y]]: F2[Int, Int] = v | ||
^ | ||
variance-holes.scala:2: error: contravariant type A occurs in covariant position in type [-A] >: List[A] of type Lower1 | ||
type Lower1[-A] >: List[A] | ||
^ | ||
variance-holes.scala:5: error: covariant type x occurs in contravariant position in type [+x] >: F[x] of type G | ||
type G[+x] >: F[x] | ||
^ | ||
variance-holes.scala:13: error: covariant type A occurs in contravariant position in type AnyRef{type T >: A} of method foo | ||
def foo: { type T >: A } | ||
^ | ||
variance-holes.scala:17: error: covariant type A occurs in contravariant position in type AnyRef{type T <: A} of value x | ||
def foo(x: { type T <: A }): Unit | ||
^ | ||
variance-holes.scala:20: error: covariant type A occurs in contravariant position in type <: AnyRef{type T >: A} of type x | ||
class RefinedLower[+A, x <: { type T >: A }] | ||
^ | ||
variance-holes.scala:21: error: covariant type A occurs in contravariant position in type A of value x_= | ||
private[this] class PrivateThis[+A](var x: A) | ||
^ | ||
7 errors |
Oops, something went wrong.