File tree Expand file tree Collapse file tree 4 files changed +41
-0
lines changed
neg-custom-args/fatal-warnings
pos-special/fatal-warnings Expand file tree Collapse file tree 4 files changed +41
-0
lines changed Original file line number Diff line number Diff line change
1
+ -- Error: tests/neg-custom-args/fatal-warnings/enum-variance.scala:2:12 ------------------------------------------------
2
+ 2 | case Refl(f: T => T) // error: covariant T in contravariant position... enum case may require explicit type parameters
3
+ | ^^^^^^^^^
4
+ | covariant type T occurs in contravariant position in type T => T of value f
5
+ | enum case class Refl may require explicit type parameters to resolve this issue
Original file line number Diff line number Diff line change
1
+ enum View [+ T ]:
2
+ case Refl (f : T => T ) // error: covariant T in contravariant position... enum case may require explicit type parameters
Original file line number Diff line number Diff line change
1
+ package asts
2
+
3
+ enum Ast [- T >: Null ]:
4
+ case DefDef ()
5
+
6
+ trait AstImpl [T >: Null ]:
7
+ type Ast = asts.Ast [T ]
8
+ type DefDef = Ast .DefDef [T ]
9
+ end AstImpl
10
+
11
+ object untpd extends AstImpl [Null ]:
12
+
13
+ def DefDef (ast : Ast ): DefDef = ast match
14
+ case ast : DefDef => ast
15
+
16
+ end untpd
Original file line number Diff line number Diff line change
1
+ class Animal
2
+ class Dog extends Animal
3
+
4
+ enum Opt [+ T ]:
5
+ case Sm (t : T )
6
+ case None
7
+
8
+ val smDog : Opt .Sm [Dog ] = new Opt .Sm (Dog ())
9
+ val smAnimal : Opt .Sm [Animal ] = smDog
10
+
11
+ enum Show [- T ]:
12
+ case Refl (op : T => String )
13
+
14
+ def show (t : T ): String = this match
15
+ case Refl (op) => op(t)
16
+
17
+ val reflAnimal : Show .Refl [Animal ] = new Show .Refl (_.toString)
18
+ val reflDog : Show .Refl [Dog ] = reflAnimal
You can’t perform that action at this time.
0 commit comments