Skip to content

inline val class parameter in backend #3900

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
nicolasstucki opened this issue Jan 24, 2018 · 9 comments
Closed

inline val class parameter in backend #3900

nicolasstucki opened this issue Jan 24, 2018 · 9 comments

Comments

@nicolasstucki
Copy link
Contributor

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
@smarter
Copy link
Member

smarter commented Jan 24, 2018

I don't think this should compile at all.

@nicolasstucki
Copy link
Contributor Author

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.

@allanrenucci
Copy link
Contributor

Should class Foo(inline i: Int) be allowed?

@biboudis
Copy link
Contributor

I think not. It is not allowed either. WDYT?

@nicolasstucki
Copy link
Contributor Author

They should not. There is no way to inline the value of i in any of the references of i.

@allanrenucci
Copy link
Contributor

Should inline on secondary constructor parameters be rejected too?

@nicolasstucki
Copy link
Contributor Author

Yes, unless the secondary constructor is inlinable. Can it?

@allanrenucci
Copy link
Contributor

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() ?

@smarter
Copy link
Member

smarter commented Jan 25, 2018

I don't think we should support inlining secondary constructors. It's going to be complicated to implement and offers no value.

odersky added a commit that referenced this issue Jan 26, 2018
Fix #3900: add check for inline class parameters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants