File tree Expand file tree Collapse file tree 2 files changed +41
-1
lines changed
src/reflect/scala/reflect/internal
test/junit/scala/tools/nsc/interactive Expand file tree Collapse file tree 2 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -5291,6 +5291,12 @@ trait Types
5291
5291
} finally res = saved
5292
5292
}
5293
5293
5294
+ private def needClearBaseTypeCache (ct : CompoundType ) = {
5295
+ // was `ct.baseClasses.exists(changedSymbols)`, but `baseClasses` may force types early (scala/bug#13112)
5296
+ val cache = ct.baseTypeSeqCache
5297
+ cache != null && changedSymbols.exists(cache.baseTypeIndex(_) >= 0 )
5298
+ }
5299
+
5294
5300
def apply (tp : Type ): Unit = tp match {
5295
5301
case _ if seen.containsKey(tp) =>
5296
5302
@@ -5304,7 +5310,7 @@ trait Types
5304
5310
}
5305
5311
seen.put(tp, res)
5306
5312
5307
- case ct : CompoundType if ct.baseClasses.exists(changedSymbols ) =>
5313
+ case ct : CompoundType if needClearBaseTypeCache(ct ) =>
5308
5314
ct.invalidatedCompoundTypeCaches()
5309
5315
res = true
5310
5316
seen.put(tp, res)
Original file line number Diff line number Diff line change
1
+ package scala .tools .nsc .interactive
2
+
3
+ import org .junit .Test
4
+
5
+ import scala .reflect .internal .util .BatchSourceFile
6
+ import scala .tools .nsc .interactive .tests .InteractiveTest
7
+
8
+ class PresentationCompilerTest {
9
+ @ Test def run13112 (): Unit = {
10
+ t13112.main(null )
11
+ }
12
+ }
13
+
14
+ object t13112 extends InteractiveTest {
15
+ val code =
16
+ """ case class Foo(name: String = "")
17
+ |object Foo extends Foo("")
18
+ |""" .stripMargin
19
+
20
+ override def execute (): Unit = {
21
+ val source = new BatchSourceFile (" Foo.scala" , code)
22
+
23
+ val res = new Response [Unit ]
24
+ compiler.askReload(List (source), res)
25
+ res.get
26
+ askLoadedTyped(source).get
27
+
28
+ // the second round was failing (see scala/bug#13112 for details)
29
+ compiler.askReload(List (source), res)
30
+ res.get
31
+ val reloadRes = askLoadedTyped(source).get
32
+ assert(reloadRes.isLeft)
33
+ }
34
+ }
You can’t perform that action at this time.
0 commit comments