Skip to content

Commit f771395

Browse files
authored
Merge pull request scala#5671 from retronym/topic/stubby-2
Avoid compiler crash with missing transitive dependencies
2 parents 96a7617 + ad13063 commit f771395

File tree

5 files changed

+68
-7
lines changed

5 files changed

+68
-7
lines changed

src/compiler/scala/tools/nsc/Global.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,10 +953,11 @@ class Global(var currentSettings: Settings, var reporter: Reporter)
953953
definitions.isDefinitionsInitialized
954954
&& rootMirror.isMirrorInitialized
955955
)
956-
override def isPastTyper = (
956+
override def isPastTyper = isPast(currentRun.typerPhase)
957+
def isPast(phase: Phase) = (
957958
(curRun ne null)
958959
&& isGlobalInitialized // defense against init order issues
959-
&& (globalPhase.id > currentRun.typerPhase.id)
960+
&& (globalPhase.id > phase.id)
960961
)
961962

962963
// TODO - trim these to the absolute minimum.

src/compiler/scala/tools/nsc/backend/ScalaPrimitives.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,9 +446,10 @@ abstract class ScalaPrimitives {
446446
inform(s"Unknown primitive method $cls.$method")
447447
else alts foreach (s =>
448448
addPrimitive(s,
449-
s.info.paramTypes match {
450-
case tp :: _ if code == ADD && tp =:= StringTpe => CONCAT
451-
case _ => code
449+
if (code != ADD) code
450+
else exitingTyper(s.info).paramTypes match {
451+
case tp :: _ if tp =:= StringTpe => CONCAT
452+
case _ => code
452453
}
453454
)
454455
)

src/reflect/scala/reflect/internal/Symbols.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ trait Symbols extends api.Symbols { self: SymbolTable =>
809809

810810
final def isDerivedValueClass =
811811
isClass && !hasFlag(PACKAGE | TRAIT) &&
812-
info.firstParent.typeSymbol == AnyValClass && !isPrimitiveValueClass
812+
!phase.erasedTypes && info.firstParent.typeSymbol == AnyValClass && !isPrimitiveValueClass
813813

814814
final def isMethodWithExtension =
815815
isMethod && owner.isDerivedValueClass && !isParamAccessor && !isConstructor && !hasFlag(SUPERACCESSOR) && !isMacro && !isSpecialized

src/reflect/scala/reflect/internal/pickling/UnPickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ abstract class UnPickler {
377377

378378
def readThisType(): Type = {
379379
val sym = readSymbolRef() match {
380-
case stub: StubSymbol => stub.setFlag(PACKAGE)
380+
case stub: StubSymbol => stub.setFlag(PACKAGE | MODULE)
381381
case sym => sym
382382
}
383383
ThisType(sym)

test/files/run/t10171/Test.scala

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import scala.tools.partest._
2+
import java.io.File
3+
4+
object Test extends StoreReporterDirectTest {
5+
def code = ???
6+
7+
def compileCode(code: String) = {
8+
val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator")
9+
compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code)
10+
}
11+
12+
def library = """
13+
package a {
14+
package b {
15+
class C { class D }
16+
}
17+
}
18+
package z {
19+
class Base {
20+
type S = String
21+
def foo(s: S): a.b.C#D = null
22+
}
23+
class Sub extends Base {
24+
def sub = "sub"
25+
}
26+
}
27+
"""
28+
29+
def client = """
30+
class Client { new z.Sub().sub }
31+
"""
32+
33+
def deleteClass(s: String) = {
34+
val f = new File(testOutput.path, s + ".class")
35+
assert(f.exists)
36+
f.delete()
37+
}
38+
39+
def deletePackage(s: String) = {
40+
val f = new File(testOutput.path, s)
41+
assert(f.exists)
42+
f.delete()
43+
}
44+
45+
def assertNoErrors(): Unit = {
46+
assert(storeReporter.infos.isEmpty, storeReporter.infos.mkString("\n"))
47+
storeReporter.reset()
48+
}
49+
def show(): Unit = {
50+
compileCode(library)
51+
assertNoErrors()
52+
deleteClass("a/b/C$D")
53+
deleteClass("a/b/C")
54+
deletePackage("a/b")
55+
compileCode(client)
56+
assertNoErrors()
57+
}
58+
}
59+

0 commit comments

Comments
 (0)