File tree 4 files changed +35
-4
lines changed
src/dotty/tools/dotc/transform 4 files changed +35
-4
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
37
37
*/
38
38
override def transformSym (sym : SymDenotation )(implicit ctx : Context ): SymDenotation = {
39
39
def ownerBecomesConstructor (owner : Symbol ): Boolean =
40
- (owner.isLocalDummy || owner.isTerm && ! owner.is(Method | Lazy )) &&
40
+ (owner.isLocalDummy || owner.isTerm && ! owner.is(MethodOrLazy )) &&
41
41
owner.owner.isClass
42
42
if (ownerBecomesConstructor(sym.owner))
43
43
sym.copySymDenotation(owner = sym.owner.enclosingClass.primaryConstructor)
@@ -54,9 +54,8 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
54
54
* constructor.
55
55
*/
56
56
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 )
58
58
59
- private final val KeeperFlags = Method | Lazy
60
59
private final val MutableParamAccessor = allOf(Mutable , ParamAccessor )
61
60
62
61
override def transformTemplate (tree : Template )(implicit ctx : Context , info : TransformerInfo ): Tree = {
Original file line number Diff line number Diff line change @@ -213,7 +213,7 @@ object ExplicitOuter {
213
213
case id : Ident =>
214
214
id.tpe match {
215
215
case ref @ TermRef (NoPrefix , _) =>
216
- ref.symbol.is(Method ) && isOuter(id.symbol.owner.enclosingClass)
216
+ ref.symbol.is(Hoistable ) && isOuter(id.symbol.owner.enclosingClass)
217
217
// methods will be placed in enclosing class scope by LambdaLift, so they will get
218
218
// an outer path then.
219
219
case _ => false
@@ -225,6 +225,8 @@ object ExplicitOuter {
225
225
}
226
226
}
227
227
228
+ private final val Hoistable = Method | Lazy | Module
229
+
228
230
/** The outer prefix implied by type `tpe` */
229
231
private def outerPrefix (tpe : Type )(implicit ctx : Context ): Type = tpe match {
230
232
case tpe : TypeRef =>
Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
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
+ }
You can’t perform that action at this time.
0 commit comments