Skip to content

Commit de3bd81

Browse files
author
EnzeXing
committed
Removing warnings for returns in secondary constructors
1 parent 7efe0c6 commit de3bd81

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/src/dotty/tools/dotc/transform/init/Objects.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,11 @@ object Objects:
711711
val tpl = cls.defTree.asInstanceOf[TypeDef].rhs.asInstanceOf[Template]
712712
extendTrace(cls.defTree) { eval(tpl, ref, cls, cacheResult = true) }
713713
else
714-
extendTrace(ddef) { eval(ddef.rhs, ref, cls, cacheResult = true) }
714+
extendTrace(ddef) {
715+
Returns.installHandler(ctor)
716+
eval(ddef.rhs, ref, cls, cacheResult = true)
717+
Returns.popHandler(ctor)
718+
}
715719
else
716720
// no source code available
717721
Bottom
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Foo (var x: Int) {
2+
def this(a : Int, b : Int) = {
3+
this(a + b)
4+
return
5+
}
6+
val y = x
7+
}
8+
9+
object A {
10+
val a = new Foo(2, 3)
11+
val b = a.y
12+
}

0 commit comments

Comments
 (0)