aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2016-08-14 10:54:20 +0300
committerGitHub <noreply@github.com>2016-08-14 10:54:20 +0300
commit3265323f96f69bded3edb832519825bc7c89e40f (patch)
tree8ab4d2b88319fc6c7e91ee91b7e07860e83cda2c /src/dotty/tools
parent5429e1dec30095893dd92ecfbb6b5775f607aa35 (diff)
parent4e95a105869ec2d978d5e7e0a3f78442e19b2fe5 (diff)
downloaddotty-3265323f96f69bded3edb832519825bc7c89e40f.tar.gz
dotty-3265323f96f69bded3edb832519825bc7c89e40f.tar.bz2
dotty-3265323f96f69bded3edb832519825bc7c89e40f.zip
Merge pull request #1414 from dotty-staging/add-array-strawman
Add arrays to collection strawman
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/backend/jvm/DottyBackendInterface.scala4
-rw-r--r--src/dotty/tools/dotc/core/Substituters.scala13
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala4
-rw-r--r--src/dotty/tools/dotc/transform/ElimByName.scala3
-rw-r--r--src/dotty/tools/dotc/transform/LambdaLift.scala16
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala3
-rw-r--r--src/dotty/tools/dotc/typer/TypeAssigner.scala8
7 files changed, 30 insertions, 21 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index f42a8eee2..30934605b 100644
--- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -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 {
diff --git a/src/dotty/tools/dotc/core/Substituters.scala b/src/dotty/tools/dotc/core/Substituters.scala
index 0d1c78e2f..23683608a 100644
--- a/src/dotty/tools/dotc/core/Substituters.scala
+++ b/src/dotty/tools/dotc/core/Substituters.scala
@@ -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
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 16c77ac30..9d96f2b15 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -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
diff --git a/src/dotty/tools/dotc/transform/ElimByName.scala b/src/dotty/tools/dotc/transform/ElimByName.scala
index b65a46249..192227261 100644
--- a/src/dotty/tools/dotc/transform/ElimByName.scala
+++ b/src/dotty/tools/dotc/transform/ElimByName.scala
@@ -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)
diff --git a/src/dotty/tools/dotc/transform/LambdaLift.scala b/src/dotty/tools/dotc/transform/LambdaLift.scala
index 5fbe0343f..18b030913 100644
--- a/src/dotty/tools/dotc/transform/LambdaLift.scala
+++ b/src/dotty/tools/dotc/transform/LambdaLift.scala
@@ -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)
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index 11f167746..f917c233f 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -698,13 +698,14 @@ class Namer { typer: Typer =>
// the parent types are elaborated.
index(constr)
symbolOfTree(constr).ensureCompleted()
+
+ index(rest)(inClassContext(selfInfo))
val tparamAccessors = decls.filter(_ is TypeParamAccessor).toList
val parentTypes = ensureFirstIsClass(parents.map(checkedParentType(_, tparamAccessors)))
val parentRefs = ctx.normalizeToClassRefs(parentTypes, cls, decls)
typr.println(s"completing $denot, parents = $parents, parentTypes = $parentTypes, parentRefs = $parentRefs")
- index(rest)(inClassContext(selfInfo))
tempInfo.finalize(denot, parentRefs)
Checking.checkWellFormed(cls)
diff --git a/src/dotty/tools/dotc/typer/TypeAssigner.scala b/src/dotty/tools/dotc/typer/TypeAssigner.scala
index 1394d2e3e..c2b7b7101 100644
--- a/src/dotty/tools/dotc/typer/TypeAssigner.scala
+++ b/src/dotty/tools/dotc/typer/TypeAssigner.scala
@@ -203,12 +203,12 @@ trait TypeAssigner {
TryDynamicCallType
} else {
if (!site.isErroneous) {
+ def notAMember = d"${if (name.isTypeName) "type" else "value"} $name is not a member of $site"
ctx.error(
if (name == nme.CONSTRUCTOR) d"$site does not have a constructor"
- else if (site.derivesFrom(defn.DynamicClass)) {
- d"$name is not a member of $site\n" +
- "possible cause: maybe a wrong Dynamic method signature?"
- } else d"$name is not a member of $site", pos)
+ else if (site.derivesFrom(defn.DynamicClass)) s"$notAMember\npossible cause: maybe a wrong Dynamic method signature?"
+ else notAMember,
+ pos)
}
ErrorType
}