File tree Expand file tree Collapse file tree 3 files changed +29
-3
lines changed
compiler/src/dotty/tools/dotc/transform/init Expand file tree Collapse file tree 3 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ import util.Property
12
12
13
13
import ast .tpd .*
14
14
import config .Printers .init as printer
15
- import reporting .trace . force as log
15
+ import reporting .trace as log
16
16
17
17
import Semantic .Arg
18
18
import Semantic .NewExpr
@@ -131,7 +131,7 @@ object ParamOverridingCheck:
131
131
else
132
132
ddef.rhs match
133
133
case Block (Call (ref, argss) :: _, _) =>
134
- val args = evalArgs(argss.flatten, thisV, thisV.klass )
134
+ val args = evalArgs(argss.flatten, thisV, cls )
135
135
thisV.callConstructor(ref.symbol, args)
136
136
137
137
}
@@ -215,7 +215,16 @@ object ParamOverridingCheck:
215
215
Skolem (source)
216
216
217
217
case tmref : TermRef if tmref.prefix == NoPrefix =>
218
- Unknown (source)
218
+ val sym = tmref.symbol
219
+
220
+ if sym.is(Flags .Param ) && sym.owner.isConstructor then
221
+ val enclosingClass = sym.owner.enclosingClass.asClass
222
+ if enclosingClass == klass then
223
+ thisV.field(sym)
224
+ else
225
+ Unknown (source)
226
+ else
227
+ Unknown (source)
219
228
220
229
case tmref : TermRef =>
221
230
val cls = tmref.widenSingleton.classSymbol
Original file line number Diff line number Diff line change
1
+ class A (val y : Int ):
2
+ println(y) // should not issue a warning here
3
+ foo()
4
+ def foo () = println(y)
5
+
6
+ class B (z : Int ) extends A (z)
7
+
8
+ class C (override val y : Int ) extends B (y)
Original file line number Diff line number Diff line change
1
+ class A (val y : Int ):
2
+ println(y) // should not issue a warning here
3
+ foo()
4
+ def foo () = println(y)
5
+
6
+ class B (m : Int , n : Int ) extends A (m):
7
+ def this (z : Int ) = this (z, z)
8
+
9
+ class C (override val y : Int ) extends B (y)
You can’t perform that action at this time.
0 commit comments