Skip to content

Commit ee51ea9

Browse files
committed
Merge pull request #529 from dotty-staging/fix/#503
Fix of #503
2 parents 61ddff4 + 14d506a commit ee51ea9

File tree

4 files changed

+35
-4
lines changed

4 files changed

+35
-4
lines changed

src/dotty/tools/dotc/transform/Constructors.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
3737
*/
3838
override def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = {
3939
def ownerBecomesConstructor(owner: Symbol): Boolean =
40-
(owner.isLocalDummy || owner.isTerm && !owner.is(Method | Lazy)) &&
40+
(owner.isLocalDummy || owner.isTerm && !owner.is(MethodOrLazy)) &&
4141
owner.owner.isClass
4242
if (ownerBecomesConstructor(sym.owner))
4343
sym.copySymDenotation(owner = sym.owner.enclosingClass.primaryConstructor)
@@ -54,9 +54,8 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
5454
* constructor.
5555
*/
5656
private def mightBeDropped(sym: Symbol)(implicit ctx: Context) =
57-
sym.is(Private, butNot = KeeperFlags) && !sym.is(MutableParamAccessor)
57+
sym.is(Private, butNot = MethodOrLazy) && !sym.is(MutableParamAccessor)
5858

59-
private final val KeeperFlags = Method | Lazy
6059
private final val MutableParamAccessor = allOf(Mutable, ParamAccessor)
6160

6261
override def transformTemplate(tree: Template)(implicit ctx: Context, info: TransformerInfo): Tree = {

src/dotty/tools/dotc/transform/ExplicitOuter.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ object ExplicitOuter {
213213
case id: Ident =>
214214
id.tpe match {
215215
case ref @ TermRef(NoPrefix, _) =>
216-
ref.symbol.is(Method) && isOuter(id.symbol.owner.enclosingClass)
216+
ref.symbol.is(Hoistable) && isOuter(id.symbol.owner.enclosingClass)
217217
// methods will be placed in enclosing class scope by LambdaLift, so they will get
218218
// an outer path then.
219219
case _ => false
@@ -225,6 +225,8 @@ object ExplicitOuter {
225225
}
226226
}
227227

228+
private final val Hoistable = Method | Lazy | Module
229+
228230
/** The outer prefix implied by type `tpe` */
229231
private def outerPrefix(tpe: Type)(implicit ctx: Context): Type = tpe match {
230232
case tpe: TypeRef =>

tests/pos/i503.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class HelloWorld {
2+
def main(args: Array[String]): Unit = {
3+
object TypeBool;
4+
5+
class Fct {
6+
def g(x : Int) = TypeBool
7+
}
8+
9+
trait Fct2 {
10+
def g(x : Int) = TypeBool
11+
}
12+
}
13+
}

tests/pos/superacc.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// scenario one: supercalls in traits
2+
abstract class C {
3+
def foo: Int = 2
4+
def baz: Int = 2
5+
}
6+
7+
trait T extends C {
8+
override def foo = super.foo + 1
9+
}
10+
11+
12+
// scenario 2: supercalls in nested classes
13+
class D extends C with T {
14+
class I {
15+
val x= D.super.baz
16+
}
17+
}

0 commit comments

Comments
 (0)