Skip to content

Fix of #503 #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/dotty/tools/dotc/transform/Constructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
*/
override def transformSym(sym: SymDenotation)(implicit ctx: Context): SymDenotation = {
def ownerBecomesConstructor(owner: Symbol): Boolean =
(owner.isLocalDummy || owner.isTerm && !owner.is(Method | Lazy)) &&
(owner.isLocalDummy || owner.isTerm && !owner.is(MethodOrLazy)) &&
owner.owner.isClass
if (ownerBecomesConstructor(sym.owner))
sym.copySymDenotation(owner = sym.owner.enclosingClass.primaryConstructor)
Expand All @@ -54,9 +54,8 @@ class Constructors extends MiniPhaseTransform with SymTransformer { thisTransfor
* constructor.
*/
private def mightBeDropped(sym: Symbol)(implicit ctx: Context) =
sym.is(Private, butNot = KeeperFlags) && !sym.is(MutableParamAccessor)
sym.is(Private, butNot = MethodOrLazy) && !sym.is(MutableParamAccessor)

private final val KeeperFlags = Method | Lazy
private final val MutableParamAccessor = allOf(Mutable, ParamAccessor)

override def transformTemplate(tree: Template)(implicit ctx: Context, info: TransformerInfo): Tree = {
Expand Down
4 changes: 3 additions & 1 deletion src/dotty/tools/dotc/transform/ExplicitOuter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ object ExplicitOuter {
case id: Ident =>
id.tpe match {
case ref @ TermRef(NoPrefix, _) =>
ref.symbol.is(Method) && isOuter(id.symbol.owner.enclosingClass)
ref.symbol.is(Hoistable) && isOuter(id.symbol.owner.enclosingClass)
// methods will be placed in enclosing class scope by LambdaLift, so they will get
// an outer path then.
case _ => false
Expand All @@ -225,6 +225,8 @@ object ExplicitOuter {
}
}

private final val Hoistable = Method | Lazy | Module

/** The outer prefix implied by type `tpe` */
private def outerPrefix(tpe: Type)(implicit ctx: Context): Type = tpe match {
case tpe: TypeRef =>
Expand Down
13 changes: 13 additions & 0 deletions tests/pos/i503.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class HelloWorld {
def main(args: Array[String]): Unit = {
object TypeBool;

class Fct {
def g(x : Int) = TypeBool
}

trait Fct2 {
def g(x : Int) = TypeBool
}
}
}
17 changes: 17 additions & 0 deletions tests/pos/superacc.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// scenario one: supercalls in traits
abstract class C {
def foo: Int = 2
def baz: Int = 2
}

trait T extends C {
override def foo = super.foo + 1
}


// scenario 2: supercalls in nested classes
class D extends C with T {
class I {
val x= D.super.baz
}
}