class Foo(inline val i: Int)
emits the following error
Concrete method has no definition: Concrete method has no definition: DefDef(i,List(),List(List()),TypeTree[TypeRef(ThisType(TypeRef(NoPrefix,module class scala)),class Int)],EmptyTree)
one error found
I don't think this should compile at all.
I assume that inline should never be used in a class parameter as we cannot ensure that accesses to those field are inlined. @odersky is that the correct semantics.
Should class Foo(inline i: Int) be allowed?
I think not. It is not allowed either. WDYT?
They should not. There is no way to inline the value of i in any of the references of i.
Should inline on secondary constructor parameters be rejected too?
Yes, unless the secondary constructor is inlinable. Can it?
I don't see why a secondary constructor could not be inlined, although I imagine it is not the same mechanism as inlining a normal function call:
class Foo() {
def this(x: Int) = this()
}
new Foo(1) // inlined to new Foo() ?
I don't think we should support inlining secondary constructors. It's going to be complicated to implement and offers no value.