File tree Expand file tree Collapse file tree 3 files changed +61
-1
lines changed
compiler/src/dotty/tools/dotc/transform Expand file tree Collapse file tree 3 files changed +61
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,9 @@ class ParamForwarding(thisTransformer: DenotTransformer) {
55
55
stat match {
56
56
case stat : ValDef =>
57
57
val sym = stat.symbol.asTerm
58
- if (sym is (ParamAccessor , butNot = Mutable )) {
58
+ if (sym.is(ParamAccessor , butNot = Mutable ) && ! sym.info.isInstanceOf [ExprType ]) {
59
+ // ElimByName gets confused with methods returning an ExprType,
60
+ // so avoid param forwarding if parameter is by name. See i1766.scala
59
61
val idx = superArgs.indexWhere(_.symbol == sym)
60
62
if (idx >= 0 && superParamNames(idx) == stat.name) { // supercall to like-named parameter
61
63
val alias = inheritedAccessor(sym)
Original file line number Diff line number Diff line change
1
+ class X (val y : String )
2
+ class Y (y : => String ) extends X (y)
3
+ class Z (z : => String ) extends X (z)
Original file line number Diff line number Diff line change
1
+ object Test {
2
+ def main (args : Array [String ]) = {
3
+
4
+ implicit val world : String = " world!"
5
+
6
+ val i1 = (implicit (s : String ) => s.length > 2 )
7
+ val i2 = {implicit (s : String ) => s.length > 2 }
8
+
9
+ assert(i1)
10
+ assert(i2)
11
+
12
+ val x : implicit String => Boolean = { implicit (s : String ) => s.length > 2 }
13
+
14
+ val xx : implicit (String , Int ) => Int = implicit (x : String , y : Int ) => x.length + y
15
+
16
+ val y : String => Boolean = x
17
+
18
+ object nested {
19
+ implicit val empty : String = " "
20
+ assert(! x)
21
+ }
22
+
23
+ val yy : (String , Int ) => Any = xx
24
+
25
+ val z1 : implicit String => Boolean = implicitly[String ].length >= 2
26
+ assert(z1)
27
+
28
+ type StringlyBool = implicit String => Boolean
29
+
30
+ val z2 : StringlyBool = implicitly[String ].length >= 2
31
+ assert(z2)
32
+
33
+ type Stringly [T ] = implicit String => T
34
+
35
+ val z3 : Stringly [Boolean ] = implicitly[String ].length >= 2
36
+ assert(z3)
37
+
38
+ type GenericImplicit [X ] = implicit X => Boolean
39
+
40
+ val z4 : GenericImplicit [String ] = implicitly[String ].length >= 2
41
+ assert(z4)
42
+
43
+ val b = x(" hello" )
44
+
45
+ val b1 : Boolean = b
46
+
47
+ val bi = x
48
+
49
+ val bi1 : Boolean = bi
50
+
51
+ val c = xx(" hh" , 22 )
52
+
53
+ val c1 : Int = c
54
+ }
55
+ }
You can’t perform that action at this time.
0 commit comments