Skip to content

Commit 9556c5f

Browse files
authored
Do not create forwarders when an error has already occurred (#26220)
Fixes #26037
1 parent 8bad866 commit 9556c5f

5 files changed

Lines changed: 26 additions & 4 deletions

File tree

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,9 @@ class Namer { typer: Typer =>
12681268
it suffices to check if symbol is the same class. */
12691269
cls == id.symbol
12701270
case _ => false
1271-
if !sym.isAccessibleFrom(pathType) then
1271+
if mbr.info.isInstanceOf[ErrorType] then
1272+
No("already has an error")
1273+
else if !sym.isAccessibleFrom(pathType) then
12721274
No("is not accessible")
12731275
else if sym.isConstructor || sym.is(ModuleClass) || sym.is(Bridge) || sym.is(PhantomSymbol) || sym.isAllOf(JavaModule) then
12741276
Skip

compiler/test/dotc/neg-best-effort-pickling.excludelist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ i11226.scala # missing type
2020
i974.scala # cyclic reference
2121
i13864.scala # missing symbol in pickling
2222
type-params.scala # recursion limit exceeded
23+
26037.scala # recursion limit exceeded
2324

2425
unsafe-dollar-in-name.scala # missing owner in unpickler
2526
unsafe-dollar-in-name-2.scala # missing owner in unpickler

compiler/test/dotty/tools/dotc/Playground.scala

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import org.junit.Ignore
1010
import CompilationTests.{*, given}
1111
import CompilationTest.aggregateTests
1212

13-
@Test def example: Unit =
14-
implicit val testGroup: TestGroup = TestGroup("single-test")
13+
@Test def example(): Unit =
14+
given testGroup: TestGroup = TestGroup("single-test")
1515
// can add, e.g., .and("-some-option")
1616
val options = defaultOptions
1717
// can also use `compileDir` (single test as a dir), `compileFilesInDir` (all tests within a dir)
@@ -21,3 +21,14 @@ import org.junit.Ignore
2121
val compilationTest = withCoverage(aggregateTests(test))
2222
runWithCoverageOrFallback[TestKind](compilationTest, testGroup.name)
2323

24+
@Test def bestEffortTasty(): Unit =
25+
given testGroup: TestGroup = TestGroup("single-test")
26+
// can add, e.g., .and("-some-option")
27+
val options = TestConfiguration.bestEffortBaselineOptions
28+
// make sure we only test one thing at a time, despite the framework requiring an entire dir + filters
29+
val testFile = "26037.scala"
30+
dotc.comptest.compileBestEffortTastyInDir(
31+
"tests/neg", options,
32+
picklingFilter = FileFilter.include(List(testFile)),
33+
unpicklingFilter = FileFilter.include(List(testFile))
34+
).checkNoCrash()

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1684,7 +1684,7 @@ trait ParallelTesting extends RunnerOrchestration with CoverageSupport:
16841684
assert(!flags.options.contains(bestEffortFlag), "Best effort compilation flag should not be added manually")
16851685

16861686
val outDir = new JFile(defaultOutputDir, testGroup.name)
1687-
val sourceDir = new JFile(f)
1687+
val sourceDir = TestSources.getPath(f).toFile
16881688
checkRequirements(f, sourceDir, outDir)
16891689

16901690
val (dirsStep1, filteredPicklingFiles) = compilationTargets(sourceDir, picklingFilter)

tests/neg/26037.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
object core:
2+
opaque type T = String | List[T] // error: illegal cyclic type
3+
object T:
4+
def make(s: String): T = s
5+
6+
object api:
7+
export core.T
8+
export core.T.*

0 commit comments

Comments
 (0)