Skip to content

Add arrays to collection strawman #1414

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 17 commits into from
Aug 14, 2016
Merged
Show file tree
Hide file tree
Changes from 11 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
4 changes: 3 additions & 1 deletion src/dotty/tools/backend/jvm/DottyBackendInterface.scala
Original file line number Diff line number Diff line change
Expand Up @@ -648,12 +648,14 @@ class DottyBackendInterface(outputDirectory: AbstractFile, val superCallsMap: Ma
originalOwner
}
def originalOwner: Symbol = {
// used to populate the EnclosingMethod attribute.
// it is very tricky in presence of classes(and annonymous classes) defined inside supper calls.
try {
if (sym.exists) {
val original = toDenot(sym).initial
val validity = original.validFor
val shiftedContext = ctx.withPhase(validity.phaseId)
val r = toDenot(sym)(shiftedContext).maybeOwner.enclosingClass(shiftedContext)
val r = toDenot(sym)(shiftedContext).maybeOwner.lexicallyEnclosingClass(shiftedContext)
r
} else NoSymbol
} catch {
Expand Down
13 changes: 6 additions & 7 deletions src/dotty/tools/dotc/core/Substituters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ trait Substituters { this: Context =>
}
if (sym.isStatic && !existsStatic(from)) tp
else {
val prefix1 = substDealias(tp.prefix, from, to, theMap)
if (prefix1 ne tp.prefix) tp.derivedSelect(prefix1)
else if (sym.isAliasType) {
val hi = sym.info.bounds.hi
val hi1 = substDealias(hi, from, to, theMap)
if (hi1 eq hi) tp else hi1
tp.info match {
case TypeAlias(alias) =>
val alias1 = substDealias(alias, from, to, theMap)
if (alias1 ne alias) return alias1
case _ =>
}
else tp
tp.derivedSelect(substDealias(tp.prefix, from, to, theMap))
}
case _: ThisType | _: BoundType | NoPrefix =>
tp
Expand Down
4 changes: 4 additions & 0 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,10 @@ object SymDenotations {
enclClass(symbol, false)
}

/** A class that in source code would be lexically enclosing */
final def lexicallyEnclosingClass(implicit ctx: Context): Symbol =
if (!exists || isClass) symbol else owner.lexicallyEnclosingClass

/** A symbol is effectively final if it cannot be overridden in a subclass */
final def isEffectivelyFinal(implicit ctx: Context): Boolean =
is(PrivateOrFinal) || !owner.isClass || owner.is(ModuleOrFinal) || owner.isAnonymousClass
Expand Down
3 changes: 2 additions & 1 deletion src/dotty/tools/dotc/transform/ElimByName.scala
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ class ElimByName extends MiniPhaseTransform with InfoTransformer { thisTransform
if qual.tpe.derivesFrom(defn.FunctionClass(0)) && isPureExpr(qual) =>
qual
case _ =>
val inSuper = if (ctx.mode.is(Mode.InSuperCall)) InSuperCall else EmptyFlags
val meth = ctx.newSymbol(
ctx.owner, nme.ANON_FUN, Synthetic | Method, MethodType(Nil, Nil, argType))
ctx.owner, nme.ANON_FUN, Synthetic | Method | inSuper, MethodType(Nil, Nil, argType))
Closure(meth, _ => arg.changeOwner(ctx.owner, meth))
}
ref(defn.dummyApply).appliedToType(argType).appliedTo(argFun)
Expand Down
16 changes: 9 additions & 7 deletions src/dotty/tools/dotc/transform/LambdaLift.scala
Original file line number Diff line number Diff line change
Expand Up @@ -364,13 +364,15 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
if (lOwner is Package) {
val encClass = local.enclosingClass
val topClass = local.topLevelClass
// member of a static object
if (encClass.isStatic && encClass.isProperlyContainedIn(topClass)) {
// though the second condition seems weird, it's not true for symbols which are defined in some
// weird combinations of super calls.
(encClass, EmptyFlags)
} else if (encClass.is(ModuleClass, butNot = Package) && encClass.isStatic) // needed to not cause deadlocks in classloader. see t5375.scala
(encClass, EmptyFlags)
val preferEncClass =
encClass.isStatic &&
// non-static classes can capture owners, so should be avoided
(encClass.isProperlyContainedIn(topClass) ||
// can be false for symbols which are defined in some weird combination of supercalls.
encClass.is(ModuleClass, butNot = Package)
// needed to not cause deadlocks in classloader. see t5375.scala
)
if (preferEncClass) (encClass, EmptyFlags)
else (topClass, JavaStatic)
}
else (lOwner, EmptyFlags)
Expand Down
Loading