File tree Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Expand file tree Collapse file tree 3 files changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+
2
+ class Ann (x : Any ) extends annotation.Annotation
3
+ object Message :
4
+ implicit def toNoExplanation (str : String ): Message @ Ann (str) = ???
5
+ class Message
6
+
7
+ object report :
8
+ def error (x : Message ): Unit = ???
9
+
10
+ def test =
11
+ report.error(" a" ) // works
12
+ report.error(" a" .stripMargin) // error
Original file line number Diff line number Diff line change
1
+
2
+ trait Food [+ A ]
3
+ trait Animal
4
+ object Animal {
5
+ extension (animal : Animal ) def consume [A ](weights : Food [A ]): A = ???
6
+ }
7
+
8
+ val animal : Animal = ???
9
+ val choices : List [Food [Int ]] = ???
10
+ val result0 : List [Any ] = choices.map(animal.consume) // compiles
11
+ // val result1: List[Int] = choices.map(animal.consume) // does not compile
12
+ val result2 : List [Int ] = choices.map(food => animal.consume(food))
13
+ val result3 : List [Int ] = choices.map(animal.consume(_))
14
+
15
+ val result4 : List [Int ] = choices.map(food => Animal .consume(animal)(food))
16
+ val result5 : List [Int ] = choices.map(Animal .consume(animal))
Original file line number Diff line number Diff line change
1
+ import scala .deriving .Mirror
2
+
3
+ case class A (x : Int , y : String )
4
+
5
+ trait SomeTrait [T ]
6
+
7
+ object SomeTrait :
8
+ given [T ]: SomeTrait [T ] with {}
9
+
10
+ def f1 [T ](using p : Mirror .ProductOf [T ]): Tuple .Elem [p.MirroredElemTypes , 0 ] = ???
11
+
12
+ def f2 [T , R ](f : T => R )(using SomeTrait [R ]) = ???
13
+
14
+ // Scala3.3 is fine, 3.4 has compilation errors, p MirroredElemTypes type is missing and has been changed to Nothing
15
+ val x = f2(_ => f1[A ])
You can’t perform that action at this time.
0 commit comments