File tree Expand file tree Collapse file tree 2 files changed +40
-7
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +40
-7
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,15 @@ object NamerOps:
14
14
* @param ctor the constructor
15
15
*/
16
16
def effectiveResultType (ctor : Symbol , paramss : List [List [Symbol ]])(using Context ): Type =
17
- paramss match
17
+ var resType = paramss match
18
18
case TypeSymbols (tparams) :: _ =>
19
- var resType = ctor.owner.typeRef.appliedTo(tparams.map(_.typeRef))
20
- for params <- paramss; param <- params do
21
- if param.is(Tracked ) then
22
- resType = RefinedType (resType, param.name, param.termRef)
23
- resType
24
- case _ => ctor.owner.typeRef
19
+ ctor.owner.typeRef.appliedTo(tparams.map(_.typeRef))
20
+ case _ =>
21
+ ctor.owner.typeRef
22
+ for params <- paramss; param <- params do
23
+ if param.is(Tracked ) then
24
+ resType = RefinedType (resType, param.name, param.termRef)
25
+ resType
25
26
26
27
/** If isConstructor, make sure it has at least one non-implicit parameter list
27
28
* This is done by adding a () in front of a leading old style implicit parameter,
Original file line number Diff line number Diff line change
1
+ trait Animal
2
+ class Dog extends Animal
3
+ class Cat extends Animal
4
+
5
+ object Test1 :
6
+
7
+ abstract class Bar { val x : Animal }
8
+ val bar : Bar { val x : Cat } = new Bar { val x = new Cat } // error, but should work
9
+
10
+ trait Foo { val x : Animal }
11
+ val foo : Foo { val x : Cat } = new Foo { val x = new Cat } // error, but should work
12
+
13
+ object Test2 :
14
+ abstract class Bar (tracked val x : Animal )
15
+ val b = new Bar (new Cat )
16
+ val bar : Bar { val x : Cat } = new Bar (new Cat ) // ok
17
+
18
+ trait Foo (tracked val x : Animal )
19
+ val foo : Foo { val x : Cat } = new Foo (new Cat ) // ok
20
+
21
+ object Test3 :
22
+ trait Vec (tracked val size : Int )
23
+ class Vec8 extends Vec (8 )
24
+
25
+ abstract class Lst (tracked val size : Int )
26
+ class Lst8 extends Lst (8 )
27
+
28
+ val v8a : Vec { val size : 8 } = new Vec8 // error, but should work
29
+ val v8b : Vec { val size : 8 } = new Vec (8 ) // ok
30
+
31
+ val l8a : Lst { val size : 8 } = new Lst8 // error, but should work
32
+ val l8b : Lst { val size : 8 } = new Lst (8 ) // ok
You can’t perform that action at this time.
0 commit comments