Skip to content

Commit 62d62df

Browse files
committed
Fix compiler crash when using betasty with missing java classfiles
1 parent 4518ce5 commit 62d62df

File tree

6 files changed

+35
-13
lines changed

6 files changed

+35
-13
lines changed

Diff for: compiler/src/dotty/tools/dotc/semanticdb/SemanticSymbolBuilder.scala

+9-3
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,15 @@ class SemanticSymbolBuilder:
9090
b.append('+').append(idx + 1)
9191
case _ =>
9292
end find
93-
val sig = sym.signature
94-
val targetName = sym.targetName
95-
find(sym => sym.signature == sig && sym.targetName == targetName)
93+
try
94+
val sig = sym.signature
95+
val targetName = sym.targetName
96+
find(sym => sym.signature == sig && sym.targetName == targetName)
97+
catch
98+
// sym.signature might not exist
99+
// this solves tests/best-effort/compiler-semanticdb-crash
100+
case _: MissingType if ctx.usedBestEffortTasty =>
101+
96102

97103
def addDescriptor(sym: Symbol): Unit =
98104
if sym.is(ModuleClass) then

Diff for: compiler/test/dotc/neg-best-effort-pickling.excludelist

+6-6
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ curried-dependent-ift.scala
1313
i17121.scala
1414
illegal-match-types.scala
1515
i13780-1.scala
16-
i20317a.scala
17-
i11226.scala
18-
i974.scala
19-
i13864.scala
16+
17+
i20317a.scala # recursion limit exceeded
18+
i11226.scala # missing type
19+
i974.scala # cyclic reference
20+
i13864.scala # missing symbol in pickling
2021

2122
# semantic db generation fails in the first compilation
22-
i1642.scala
23-
i15158.scala
23+
i15158.scala # cyclic reference - stack overflow

Diff for: compiler/test/dotty/tools/vulpix/ParallelTesting.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -1212,7 +1212,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
12121212
* of betasty files.
12131213
*/
12141214
def checkNoBestEffortError()(implicit summaryReport: SummaryReporting): this.type = {
1215-
val test = new NoBestEffortErrorsTest(targets, times, threadLimit, shouldFail || shouldSuppressOutput).executeTestSuite()
1215+
val test = new NoBestEffortErrorsTest(targets, times, threadLimit, shouldFail).executeTestSuite()
12161216

12171217
cleanup()
12181218

@@ -1761,7 +1761,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
17611761
val bestEffortDir = new JFile(step1OutDir, s"META-INF${JFile.separator}best-effort")
17621762

17631763
val step2Compilation = JointCompilationSource(
1764-
testGroup.name, step2SourceFiles, flags.and(withBetastyFlag).and(semanticDbFlag), step2OutDir, fromTasty = WithBestEffortTasty(bestEffortDir)
1764+
testGroup.name, step2SourceFiles, flags.and(bestEffortFlag).and(withBetastyFlag).and(semanticDbFlag), step2OutDir, fromTasty = WithBestEffortTasty(bestEffortDir)
17651765
)
17661766
(step1Compilation, step2Compilation, bestEffortDir)
17671767
}.unzip3
@@ -1770,7 +1770,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
17701770
new CompilationTest(step1Targets).keepOutput,
17711771
new CompilationTest(step2Targets).keepOutput,
17721772
bestEffortDirs,
1773-
true
1773+
shouldDelete = true
17741774
)
17751775
}
17761776

@@ -1824,7 +1824,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
18241824

18251825
def noCrashWithCompilingDependencies()(implicit summaryReport: SummaryReporting): this.type = {
18261826
step1.checkNoBestEffortError() // Compile all files to generate the class files with best effort tasty
1827-
step2.checkCompile() // Compile with best effort tasty
1827+
step2.checkNoBestEffortError() // Compile with best effort tasty
18281828

18291829
this
18301830
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package dotty.tools.backend.jvm;
2+
3+
public class ClassNode {
4+
5+
public ClassNode(int api) {
6+
}
7+
8+
public ClassNode visitMethod(int access) {
9+
return null;
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package dotty.tools.backend.jvm
2+
3+
val errorGenerator: Int = "0"
4+
def readClass(bytes: Array[Byte]): ClassNode = ???
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
def c = dotty.tools.backend.jvm.readClass(Array())

0 commit comments

Comments
 (0)