Skip to content

Commit a2c0519

Browse files
committed
fix regression: inline match crash when rhs uses private inlined methods
1 parent 1637282 commit a2c0519

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

compiler/src/dotty/tools/dotc/ast/Trees.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ object Trees {
455455
val point = span.point
456456
if name.toTermName == nme.ERROR then
457457
Span(point)
458-
else if qualifier.span.start > span.point then // right associative
458+
else if qualifier.span.exists && qualifier.span.start > span.point then // right associative
459459
val realName = name.stripModuleClassSuffix.lastPart
460460
Span(span.start, span.start + realName.length, point)
461461
else

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

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class CompilationTests {
3838
compileFilesInDir("tests/pos-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
3939
compileFile("tests/pos-special/utf8encoded.scala", defaultOptions.and("-encoding", "UTF8")),
4040
compileFile("tests/pos-special/utf16encoded.scala", defaultOptions.and("-encoding", "UTF16")),
41+
compileDir("tests/pos-special/i18589", defaultOptions.and("-Ysafe-init").without("-Ycheck:all")),
4142
// Run tests for legacy lazy vals
4243
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
4344
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),

tests/pos-special/i18589/core_0.scala

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import scala.deriving.Mirror
2+
3+
trait NamedCodec[A, R]
4+
5+
object NamedCodecPlatform {
6+
7+
final class Builder[R]() {
8+
inline def of[T](using m: Mirror.Of[T]): NamedCodec[T, R] =
9+
inline m match {
10+
case s: Mirror.SumOf[T] => sumInst(s)
11+
case _: Mirror.ProductOf[T] => productInst
12+
}
13+
14+
private inline def productInst[T]: NamedCodec[T, R] = ???
15+
private inline def sumInst[T](m: Mirror.SumOf[T]): NamedCodec[T, R] = ???
16+
}
17+
}

tests/pos-special/i18589/test_1.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
enum Data {
2+
case A, B, C
3+
}
4+
5+
@main def Test = {
6+
val builder: NamedCodecPlatform.Builder[Any] = ???
7+
builder.of[Data]
8+
}

0 commit comments

Comments
 (0)