Skip to content

Weird Case Class Compiler Error with Inline Function #12508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
cheeseng opened this issue May 18, 2021 · 17 comments · Fixed by #14537
Closed

Weird Case Class Compiler Error with Inline Function #12508

cheeseng opened this issue May 18, 2021 · 17 comments · Fixed by #14537
Assignees
Milestone

Comments

@cheeseng
Copy link

cheeseng commented May 18, 2021

Compiler version

Scala Version: 3.0.0 - 3.0.2
SBT: 1.5.2, 1.5.5

Example project here: https://github.com/cheeseng/scala3-case-class-inline-problem

Minimized code

class Test {
  inline def test(fun: => Any): Any = fun
  test {
    case class Pair[X, Y](
      x: X,
      y: Y,
    )
  }
}

Output

cheeseng@cheeseng-RAVEN:~/git/scala3-case-class-inline-problem$ sbt clean compile
[info] welcome to sbt 1.5.2 (GraalVM Community Java 1.8.0_292)
[info] loading project definition from /home/cheeseng/git/scala3-case-class-inline-problem/project
[info] loading settings for project root from build.sbt ...
[info] set current project to scala3-simple (in build file:/home/cheeseng/git/scala3-case-class-inline-problem/)
[info] Executing in batch mode. For better performance use sbt's shell
[success] Total time: 0 s, completed May 18, 2021 10:31:40 AM
[info] compiling 1 Scala source to /home/cheeseng/git/scala3-case-class-inline-problem/target/scala-3.0.0/classes ...
[error] -- Error: /home/cheeseng/git/scala3-case-class-inline-problem/src/main/scala/Test.scala:3:2 
[error] 3 |  inline def test(fun: => Any): Any = fun
[error]   |  ^
[error]   |bad parameter reference Pair.this.X at inlining
[error]   |the parameter is type X in class Pair but the prefix (Pair.this : Pair[X, Y])
[error]   |does not define any corresponding arguments.
[error]   |idx = 0, args = List()
[error] 4 |  test {
[error] 5 |    case class Pair[X, Y](
[error] 6 |      x: X,
[error] 7 |      y: Y,
[error] 8 |    )
[error] 9 |  }
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed May 18, 2021 10:31:43 AM

Expectation

The code should compile without error.

@nicolasstucki
Copy link
Contributor

Minimizes slightly

class Test {
  inline def test(fun: Any): Any = ???
  test {
    case class Foo[X](x: X)
  }
}

@TomasMikula
Copy link
Contributor

Note that this is a regression introduced between 3.0.0-RC1 and 3.0.0-RC2.

TomasMikula added a commit to TomasMikula/libretto that referenced this issue May 20, 2021
@cheeseng
Copy link
Author

@nicolasstucki @TomasMikula Fyi I updated the example project to use Scala 3.0.1 but unfortunately it still encounters the same problem.

@cheeseng
Copy link
Author

@nicolasstucki @TomasMikula Fyi I updated the example project to use Scala 3.0.2-RC1, but unfortunately it still encounters the same problem:

cheeseng@cheeseng-RAVEN:~/git/scala3-case-class-inline-problem$ sbt clean compile
[info] welcome to sbt 1.5.2 (GraalVM Community Java 1.8.0_302)
[info] loading global plugins from /home/cheeseng/.sbt/1.0/plugins
[info] loading project definition from /home/cheeseng/git/scala3-case-class-inline-problem/project
[info] loading settings for project root from build.sbt ...
[info] set current project to scala3-simple (in build file:/home/cheeseng/git/scala3-case-class-inline-problem/)
[info] Executing in batch mode. For better performance use sbt's shell
[success] Total time: 0 s, completed Aug 17, 2021 8:49:06 PM
[info] compiling 1 Scala source to /home/cheeseng/git/scala3-case-class-inline-problem/target/scala-3.0.2-RC1/classes ...
[error] -- Error: /home/cheeseng/git/scala3-case-class-inline-problem/src/main/scala/Test.scala:3:2 
[error] 3 |  inline def test(fun: => Any): Any = fun
[error]   |  ^
[error]   |bad parameter reference Pair.this.X at inlining
[error]   |the parameter is type X in class Pair but the prefix (Pair.this : Pair[X, Y])
[error]   |does not define any corresponding arguments.
[error]   |idx = 0, args = List()
[error] 4 |  test {
[error] 5 |    case class Pair[X, Y](
[error] 6 |      x: X,
[error] 7 |      y: Y,
[error] 8 |    )
[error] 9 |  }
[error] one error found
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
[error] Total time: 3 s, completed Aug 17, 2021 8:49:09 PM

@cheeseng
Copy link
Author

@nicolasstucki @TomasMikula Fyi I updated the example project to use Scala 3.0.2 but unfortunately it still encounters the same problem.

The example project is at:

https://github.com/cheeseng/scala3-case-class-inline-problem

@cheeseng
Copy link
Author

@nicolasstucki @TomasMikula Fyi I updated the example project to use Scala 3.1.0 but unfortunately it still encounters the same problem:

The example project is at:

https://github.com/cheeseng/scala3-case-class-inline-problem

@nicolasstucki
Copy link
Contributor

Minimized further to

class Test {
  inline def test(fun: Any): Any = ???
  test {
    class Foo[X]:
      def x: X = ???
      def foo: Unit = this.x.toString
  }
}

@LPTK
Copy link
Contributor

LPTK commented Dec 7, 2021

This regression is quite a blocker for us. Any idea if it'll be resolved soon?

@nicolasstucki
Copy link
Contributor

It looks like the bug was introduced in 0241150

@odersky odersky removed their assignment Jan 17, 2022
@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 17, 2022

changeOwner throws a dotty.tools.dotc.core.TypeError when trying to change the owner of

{
  class Foo[X]:
      def x: X = ???
      def foo: Unit = this.x.toString
  ()
}
Stack trace
dotty.tools.dotc.core.TypeError: bad parameter reference Foo.this.X at inlining
the parameter is type X in class Foo but the prefix (Foo.this : Foo[X])
does not define any corresponding arguments.
idx = 0, args = List()
        at dotty.tools.dotc.core.Types$NamedType.argDenot(Types.scala:2326)
        at dotty.tools.dotc.core.Types$NamedType.fromDesignator$1(Types.scala:2240)
        at dotty.tools.dotc.core.Types$NamedType.computeDenot(Types.scala:2258)
        at dotty.tools.dotc.core.Types$NamedType.denot(Types.scala:2213)
        at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:685)
        at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:878)
        at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:669)
        at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:659)
        at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:2291)
        at dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:2572)
        at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2585)
        at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2525)
        at dotty.tools.dotc.ast.tpd$TypedTreeCopier.Select(tpd.scala:602)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1383)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1389)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1493)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1493)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformSub(Trees.scala:1497)
        at dotty.tools.dotc.ast.TreeTypeMap.transformDefs(TreeTypeMap.scala:150)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:120)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:109)
        at dotty.tools.dotc.ast.TreeTypeMap.$anonfun$2(TreeTypeMap.scala:101)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:92)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:108)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:101)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1466)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1493)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1493)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformSub(Trees.scala:1497)
        at dotty.tools.dotc.ast.TreeTypeMap.transformDefs(TreeTypeMap.scala:150)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:120)
        at dotty.tools.dotc.ast.TreeTypeMap.apply(TreeTypeMap.scala:163)
        at dotty.tools.dotc.ast.tpd$TreeOps$.loop$1(tpd.scala:819)
        at dotty.tools.dotc.ast.tpd$TreeOps$.changeOwner$extension(tpd.scala:820)
        at dotty.tools.dotc.typer.Inliner.liftedTree1$1(Inliner.scala:503)
        at dotty.tools.dotc.typer.Inliner.dotty$tools$dotc$typer$Inliner$$paramBindingDef(Inliner.scala:507)
        at dotty.tools.dotc.typer.Inliner.computeParamBindings$$anonfun$3(Inliner.scala:547)
        at scala.runtime.function.JProcedure3.apply(JProcedure3.java:15)
        at scala.runtime.function.JProcedure3.apply(JProcedure3.java:10)
        at scala.collection.LazyZip3.foreach(LazyZipOps.scala:248)
        at dotty.tools.dotc.typer.Inliner.computeParamBindings(Inliner.scala:547)
        at dotty.tools.dotc.typer.Inliner.inlined(Inliner.scala:888)
        at dotty.tools.dotc.typer.Inliner$.inlineCall(Inliner.scala:160)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:86)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:103)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:111)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1466)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:80)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.traverse$1(TreeMapWithImplicits.scala:53)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transformStats(TreeMapWithImplicits.scala:60)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1477)
        at dotty.tools.dotc.ast.TreeMapWithImplicits.transform(TreeMapWithImplicits.scala:120)
        at dotty.tools.dotc.transform.Inlining$InliningTreeMap.transform(Inlining.scala:94)
        at dotty.tools.dotc.transform.Inlining$$anon$2.transform(Inlining.scala:72)
        at dotty.tools.dotc.transform.MacroTransform.run(MacroTransform.scala:21)
        at dotty.tools.dotc.transform.Inlining.run(Inlining.scala:44)
        at dotty.tools.dotc.core.Phases$Phase.runOn$$anonfun$1(Phases.scala:308)
        at scala.collection.immutable.List.map(List.scala:246)
        at dotty.tools.dotc.core.Phases$Phase.runOn(Phases.scala:309)
        at dotty.tools.dotc.transform.Inlining.runOn(Inlining.scala:48)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:287)
        at dotty.tools.dotc.Run.compileSources(Run.scala:220)
        at dotty.tools.dotc.Run.compile(Run.scala:204)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
        at dotty.tools.dotc.Driver.process(Driver.scala:199)
        at dotty.tools.dotc.Driver.process(Driver.scala:167)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.main(Driver.scala:209)
        at dotty.tools.dotc.Main.main(Main.scala)

@nicolasstucki
Copy link
Contributor

It seems this is a more general issue that is not only present when inlining. Here is another way to trigger the same failure in changeNonLocalOwners

def fun(a: Any, b: Any = 2): Any = ???
def test =
  fun(
    b = println(1),
    a = {
      class Foo[X]:
        def x: X = ???
        def foo: Unit = this.x.toString
    }
  )
Stack trace
dotty.tools.dotc.core.TypeError: bad parameter reference Foo.this.X at typer
the parameter is type X in class Foo but the prefix (Foo.this : Foo[X])
does not define any corresponding arguments.
idx = 0, args = List()
        at dotty.tools.dotc.core.Types$NamedType.argDenot(Types.scala:2327)
        at dotty.tools.dotc.core.Types$NamedType.fromDesignator$1(Types.scala:2240)
        at dotty.tools.dotc.core.Types$NamedType.computeDenot(Types.scala:2258)
        at dotty.tools.dotc.core.Types$NamedType.denot(Types.scala:2213)
        at dotty.tools.dotc.core.Types$Type.go$1(Types.scala:685)
        at dotty.tools.dotc.core.Types$Type.findMember(Types.scala:878)
        at dotty.tools.dotc.core.Types$Type.memberBasedOnFlags(Types.scala:669)
        at dotty.tools.dotc.core.Types$Type.nonPrivateMember(Types.scala:659)
        at dotty.tools.dotc.core.Types$NamedType.memberDenot(Types.scala:2291)
        at dotty.tools.dotc.core.Types$NamedType.reload$1(Types.scala:2575)
        at dotty.tools.dotc.core.Types$NamedType.withPrefix(Types.scala:2588)
        at dotty.tools.dotc.core.Types$NamedType.derivedSelect(Types.scala:2528)
        at dotty.tools.dotc.ast.tpd$TypedTreeCopier.Select(tpd.scala:602)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1383)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1389)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1493)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1493)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformSub(Trees.scala:1497)
        at dotty.tools.dotc.ast.TreeTypeMap.transformDefs(TreeTypeMap.scala:150)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:120)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:109)
        at dotty.tools.dotc.ast.TreeTypeMap.$anonfun$2(TreeTypeMap.scala:101)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.loop$1(Decorators.scala:92)
        at dotty.tools.dotc.core.Decorators$ListDecorator$.mapconserve$extension(Decorators.scala:108)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:101)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1466)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform$$anonfun$1(Trees.scala:1493)
        at scala.collection.immutable.List.mapConserve(List.scala:472)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1493)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transformSub(Trees.scala:1497)
        at dotty.tools.dotc.ast.TreeTypeMap.transformDefs(TreeTypeMap.scala:150)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:120)
        at dotty.tools.dotc.ast.Trees$Instance$TreeMap.transform(Trees.scala:1457)
        at dotty.tools.dotc.ast.TreeTypeMap.transform(TreeTypeMap.scala:141)
        at dotty.tools.dotc.ast.TreeTypeMap.apply(TreeTypeMap.scala:163)
        at dotty.tools.dotc.ast.tpd$TreeOps$.changeNonLocalOwners$extension(tpd.scala:839)
        at dotty.tools.dotc.typer.Lifter.lift(EtaExpansion.scala:56)
        at dotty.tools.dotc.typer.Lifter.liftArg(EtaExpansion.scala:80)
        at dotty.tools.dotc.typer.Lifter.liftArgs$$anonfun$1(EtaExpansion.scala:94)
        at scala.collection.LazyZip3$$anon$9$$anon$10.next(LazyZipOps.scala:171)
        at scala.collection.immutable.List.prependedAll(List.scala:153)
        at scala.collection.immutable.List$.from(List.scala:684)
        at scala.collection.immutable.List$.from(List.scala:681)
        at scala.collection.BuildFromLowPriority2$$anon$11.fromSpecific(BuildFrom.scala:112)
        at scala.collection.BuildFromLowPriority2$$anon$11.fromSpecific(BuildFrom.scala:109)
        at scala.collection.LazyZip3.map(LazyZipOps.scala:165)
        at dotty.tools.dotc.typer.Lifter.liftArgs(EtaExpansion.scala:95)
        at dotty.tools.dotc.typer.Applications$TypedApply.<init>(Applications.scala:816)
        at dotty.tools.dotc.typer.Applications$ApplyToUntyped.<init>(Applications.scala:852)
        at dotty.tools.dotc.typer.Applications.ApplyTo(Applications.scala:1051)
        at dotty.tools.dotc.typer.Applications.ApplyTo$(Applications.scala:317)
        at dotty.tools.dotc.typer.Typer.ApplyTo(Typer.scala:119)
        at dotty.tools.dotc.typer.Applications.simpleApply$1(Applications.scala:898)
        at dotty.tools.dotc.typer.Applications.realApply$1$$anonfun$3(Applications.scala:977)
        at dotty.tools.dotc.typer.Typer.tryEither(Typer.scala:3074)
        at dotty.tools.dotc.typer.Applications.realApply$1(Applications.scala:988)
        at dotty.tools.dotc.typer.Applications.typedApply(Applications.scala:1026)
        at dotty.tools.dotc.typer.Applications.typedApply$(Applications.scala:317)
        at dotty.tools.dotc.typer.Typer.typedApply(Typer.scala:119)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2802)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2865)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3050)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr$$anonfun$1(Namer.scala:1473)
        at dotty.tools.dotc.typer.Namer.typedAhead(Namer.scala:1463)
        at dotty.tools.dotc.typer.Namer.typedAheadExpr(Namer.scala:1473)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1$$anonfun$1(Namer.scala:1710)
        at dotty.tools.dotc.typer.PrepareInlineable$.dropInlineIfError(PrepareInlineable.scala:238)
        at dotty.tools.dotc.typer.Namer.typedAheadRhs$1(Namer.scala:1710)
        at dotty.tools.dotc.typer.Namer.rhsType$1(Namer.scala:1718)
        at dotty.tools.dotc.typer.Namer.cookedRhsType$1(Namer.scala:1736)
        at dotty.tools.dotc.typer.Namer.lhsType$1(Namer.scala:1737)
        at dotty.tools.dotc.typer.Namer.inferredResultType(Namer.scala:1748)
        at dotty.tools.dotc.typer.Namer.inferredType$1(Namer.scala:1512)
        at dotty.tools.dotc.typer.Namer.valOrDefDefSig(Namer.scala:1519)
        at dotty.tools.dotc.typer.Namer.defDefSig(Namer.scala:1588)
        at dotty.tools.dotc.typer.Namer$Completer.typeSig(Namer.scala:782)
        at dotty.tools.dotc.typer.Namer$Completer.completeInCreationContext(Namer.scala:914)
        at dotty.tools.dotc.typer.Namer$Completer.complete(Namer.scala:806)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.completeFrom(SymDenotations.scala:168)
        at dotty.tools.dotc.core.Denotations$Denotation.completeInfo$1(Denotations.scala:188)
        at dotty.tools.dotc.core.Denotations$Denotation.info(Denotations.scala:190)
        at dotty.tools.dotc.core.SymDenotations$SymDenotation.ensureCompleted(SymDenotations.scala:370)
        at dotty.tools.dotc.typer.Typer.retrieveSym(Typer.scala:2744)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2769)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2864)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2956)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3006)
        at dotty.tools.dotc.typer.Typer.typedClassDef(Typer.scala:2447)
        at dotty.tools.dotc.typer.Typer.typedTypeOrClassDef$1(Typer.scala:2790)
        at dotty.tools.dotc.typer.Typer.typedNamed$1(Typer.scala:2794)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2864)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
        at dotty.tools.dotc.typer.Typer.traverse$1(Typer.scala:2956)
        at dotty.tools.dotc.typer.Typer.typedStats(Typer.scala:3006)
        at dotty.tools.dotc.typer.Typer.typedPackageDef(Typer.scala:2574)
        at dotty.tools.dotc.typer.Typer.typedUnnamed$1(Typer.scala:2835)
        at dotty.tools.dotc.typer.Typer.typedUnadapted(Typer.scala:2865)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2930)
        at dotty.tools.dotc.typer.Typer.typed(Typer.scala:2934)
        at dotty.tools.dotc.typer.Typer.typedExpr(Typer.scala:3050)
        at dotty.tools.dotc.typer.TyperPhase.liftedTree1$1(TyperPhase.scala:47)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck$$anonfun$1(TyperPhase.scala:53)
        at dotty.tools.dotc.core.Phases$Phase.monitor(Phases.scala:411)
        at dotty.tools.dotc.typer.TyperPhase.typeCheck(TyperPhase.scala:54)
        at dotty.tools.dotc.typer.TyperPhase.runOn$$anonfun$3(TyperPhase.scala:88)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.immutable.List.foreach(List.scala:333)
        at dotty.tools.dotc.typer.TyperPhase.runOn(TyperPhase.scala:88)
        at dotty.tools.dotc.Run.runPhases$1$$anonfun$1(Run.scala:259)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:15)
        at scala.runtime.function.JProcedure1.apply(JProcedure1.java:10)
        at scala.collection.ArrayOps$.foreach$extension(ArrayOps.scala:1323)
        at dotty.tools.dotc.Run.runPhases$1(Run.scala:270)
        at dotty.tools.dotc.Run.compileUnits$$anonfun$1(Run.scala:278)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
        at dotty.tools.dotc.util.Stats$.maybeMonitored(Stats.scala:68)
        at dotty.tools.dotc.Run.compileUnits(Run.scala:287)
        at dotty.tools.dotc.Run.compileSources(Run.scala:220)
        at dotty.tools.dotc.Run.compile(Run.scala:204)
        at dotty.tools.dotc.Driver.doCompile(Driver.scala:39)
        at dotty.tools.dotc.Driver.process(Driver.scala:199)
        at dotty.tools.dotc.Driver.process(Driver.scala:167)
        at dotty.tools.dotc.Driver.process(Driver.scala:179)
        at dotty.tools.dotc.Driver.main(Driver.scala:209)
        at dotty.tools.dotc.Main.main(Main.scala)

@nicolasstucki
Copy link
Contributor

nicolasstucki commented Jan 17, 2022

The issue is probably located in the TreeTypeMap or TypedTreeCopier#Select

@nicolasstucki
Copy link
Contributor

@odersky could you have a look at this issue?

JakkuSakura added a commit to JakkuSakura/dotty that referenced this issue Feb 14, 2022
…since boundSym is new, no need to use check in QuoteUtils.changeOwner)"

This reverts commit 0241150
This might help fix scala#12508
odersky added a commit to dotty-staging/dotty that referenced this issue Feb 22, 2022
Fix TreeTypeMap to correctly substitute parameters when copying local class members.

Fixes scala#12508
@LPTK
Copy link
Contributor

LPTK commented Feb 24, 2022

Thanks for fixing this!

@cheeseng
Copy link
Author

@odersky @nicolasstucki May I know if this fix is included in 3.1.2? I updated the example project to use Scala 3.1.2 and but still encounters the same error:

https://github.com/cheeseng/scala3-case-class-inline-problem

@odersky
Copy link
Contributor

odersky commented Apr 15, 2022

@cheeseng It should be in 3.1.3, which is about to be released. It is in 3.1.3 RC2.

@cheeseng
Copy link
Author

@odersky I just tested it with 3.1.3-RC2, and it works! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment