Skip to content

Commit

Permalink
fix regression: inline match crash when rhs uses private inlined meth…
Browse files Browse the repository at this point in the history
…ods (#18595)

resolves: #18589
  • Loading branch information
bishabosha authored Sep 26, 2023
2 parents b6e0e9e + a2c0519 commit 63eb5e4
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/ast/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ object Trees {
val point = span.point
if name.toTermName == nme.ERROR then
Span(point)
else if qualifier.span.start > span.point then // right associative
else if qualifier.span.exists && qualifier.span.start > span.point then // right associative
val realName = name.stripModuleClassSuffix.lastPart
Span(span.start, span.start + realName.length, point)
else
Expand Down
1 change: 1 addition & 0 deletions compiler/test/dotty/tools/dotc/CompilationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class CompilationTests {
compileFilesInDir("tests/pos-custom-args/captures", defaultOptions.and("-language:experimental.captureChecking")),
compileFile("tests/pos-special/utf8encoded.scala", defaultOptions.and("-encoding", "UTF8")),
compileFile("tests/pos-special/utf16encoded.scala", defaultOptions.and("-encoding", "UTF16")),
compileDir("tests/pos-special/i18589", defaultOptions.and("-Ysafe-init").without("-Ycheck:all")),
// Run tests for legacy lazy vals
compileFilesInDir("tests/pos", defaultOptions.and("-Ysafe-init", "-Ylegacy-lazy-vals", "-Ycheck-constraint-deps"), FileFilter.include(TestSources.posLazyValsAllowlist)),
compileDir("tests/pos-special/java-param-names", defaultOptions.withJavacOnlyOptions("-parameters")),
Expand Down
17 changes: 17 additions & 0 deletions tests/pos-special/i18589/core_0.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import scala.deriving.Mirror

trait NamedCodec[A, R]

object NamedCodecPlatform {

final class Builder[R]() {
inline def of[T](using m: Mirror.Of[T]): NamedCodec[T, R] =
inline m match {
case s: Mirror.SumOf[T] => sumInst(s)
case _: Mirror.ProductOf[T] => productInst
}

private inline def productInst[T]: NamedCodec[T, R] = ???
private inline def sumInst[T](m: Mirror.SumOf[T]): NamedCodec[T, R] = ???
}
}
8 changes: 8 additions & 0 deletions tests/pos-special/i18589/test_1.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum Data {
case A, B, C
}

@main def Test = {
val builder: NamedCodecPlatform.Builder[Any] = ???
builder.of[Data]
}

0 comments on commit 63eb5e4

Please sign in to comment.