Skip to content

inlined given resulting in runtime error java.lang.NoSuchFieldError: $outer #13334

Closed
@soronpo

Description

@soronpo

Compiler version

v3.0.2-RC1 (also tried on master branch)

Minimized code

trait DFC
given DFC = new DFC {}

trait TC
object TC:
  def foo()(using DFC): Unit = {}

  inline given (using DFC): TC = new TC:
    foo()

class Foo(using DFC):
  summon[TC]

val top = new Foo

Output

See scastie: https://scastie.scala-lang.org/yZG6miffRf6f4O6od68i2w

java.lang.NoSuchFieldError: $outer
	at Playground$$anon$2.<init>(main.scala:11)
	at Playground$Foo.<init>(main.scala:11)
	at Playground$.<clinit>(main.scala:16)
	at Main$.<clinit>(main.scala:20)
	at Main.main(main.scala)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at sbt.Run.invokeMain(Run.scala:133)
	at sbt.Run.execute$1(Run.scala:82)
	at sbt.Run.$anonfun$runWithLoader$5(Run.scala:110)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at sbt.util.InterfaceUtil$$anon$1.get(InterfaceUtil.scala:17)
	at sbt.TrapExit$App.run(TrapExit.scala:258)
	at java.lang.Thread.run(Thread.java:748)

Expectation

No runtime error.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions