Skip to content

Commit 4f60767

Browse files
authored
Merge pull request #2885 from dotty-staging/harden-ide-2
More IDE work
2 parents 1ac0b4a + 0a8a2a3 commit 4f60767

File tree

4 files changed

+12
-11
lines changed

4 files changed

+12
-11
lines changed

compiler/src/dotty/tools/dotc/core/Annotations.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,15 @@ object Annotations {
6161
def tree(implicit ctx: Context) = body
6262
}
6363

64-
case class LazyBodyAnnotation(bodyExpr: Context => Tree) extends BodyAnnotation {
64+
case class LazyBodyAnnotation(private var bodyExpr: Context => Tree) extends BodyAnnotation {
6565
private var evaluated = false
6666
private var myBody: Tree = _
6767
def tree(implicit ctx: Context) = {
6868
if (evaluated) assert(myBody != null)
6969
else {
7070
evaluated = true
7171
myBody = bodyExpr(ctx)
72+
bodyExpr = null
7273
}
7374
myBody
7475
}

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2156,7 +2156,7 @@ object Types {
21562156
}
21572157
}
21582158

2159-
case class LazyRef(refFn: () => Type) extends UncachedProxyType with ValueType {
2159+
case class LazyRef(private var refFn: () => Type) extends UncachedProxyType with ValueType {
21602160
private var myRef: Type = null
21612161
private var computed = false
21622162
def ref = {

compiler/src/dotty/tools/dotc/interactive/Interactive.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ object Interactive {
6262
sourceSymbol(sym.owner)
6363
else sym
6464

65+
private def safely[T](op: => List[T]): List[T] =
66+
try op catch { case ex: TypeError => Nil }
67+
6568
/** Possible completions at position `pos` */
6669
def completions(trees: List[SourceTree], pos: SourcePosition)(implicit ctx: Context): List[Symbol] = {
6770
val path = pathTo(trees, pos)
@@ -85,16 +88,13 @@ object Interactive {
8588
}
8689

8790
/** Possible completions of members of `prefix` which are accessible when called inside `boundary` */
88-
def completions(prefix: Type, boundary: Symbol)(implicit ctx: Context): List[Symbol] = {
89-
val boundaryCtx = ctx.withOwner(boundary)
90-
try
91+
def completions(prefix: Type, boundary: Symbol)(implicit ctx: Context): List[Symbol] =
92+
safely {
93+
val boundaryCtx = ctx.withOwner(boundary)
9194
prefix.memberDenots(completionsFilter, (name, buf) =>
9295
buf ++= prefix.member(name).altsWith(d => !d.isAbsent && d.symbol.isAccessibleFrom(prefix)(boundaryCtx))
9396
).map(_.symbol).toList
94-
catch {
95-
case ex: TypeError => Nil
9697
}
97-
}
9898

9999
/** Filter for names that should appear when looking for completions. */
100100
private[this] object completionsFilter extends NameFilter {
@@ -131,7 +131,7 @@ object Interactive {
131131
* @param includeReferences If true, include references and not just definitions
132132
*/
133133
def namedTrees(trees: List[SourceTree], includeReferences: Boolean, treePredicate: NameTree => Boolean)
134-
(implicit ctx: Context): List[SourceTree] = {
134+
(implicit ctx: Context): List[SourceTree] = safely {
135135
val buf = new mutable.ListBuffer[SourceTree]
136136

137137
trees foreach { case SourceTree(topTree, source) =>

compiler/src/dotty/tools/dotc/transform/LambdaLift.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
204204
if (enclosure.is(PackageClass)) enclosure
205205
else if (enclosure.isConstructor) markFree(sym, enclosure.owner.enclosure)
206206
else markFree(sym, enclosure.enclosure)
207-
narrowLiftedOwner(enclosure, intermediate orElse sym.enclosingClass)
207+
if (intermediate.exists) narrowLiftedOwner(enclosure, intermediate)
208208
if (!intermediate.isRealClass || enclosure.isConstructor) {
209209
// Constructors and methods nested inside traits get the free variables
210210
// of the enclosing trait or class.
@@ -384,7 +384,7 @@ class LambdaLift extends MiniPhase with IdentityDenotTransformer { thisTransform
384384
local.copySymDenotation(
385385
owner = newOwner,
386386
name = newName(local),
387-
initFlags = local.flags &~ Module | Private | maybeStatic,
387+
initFlags = local.flags &~ Module &~ Final | Private | maybeStatic,
388388
// drop Module because class is no longer a singleton in the lifted context.
389389
info = liftedInfo(local)).installAfter(thisTransform)
390390
}

0 commit comments

Comments
 (0)