-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Splicing of default getters should not special case constructors with implicits #22344
base: main
Are you sure you want to change the base?
Conversation
// Empty list is inserted for constructors where the first parameter list is implicit. | ||
// | ||
// Therefore, we need to ignore the first empty argument list. | ||
// This is needed for the test tests/neg/i12344.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to keep track of some info, this test is now tests/neg-macros/i12344.scala
and it seems that some of the discussions that led to this change are not relevant now (See #12344 (comment) and https://github.com/scala/scala3/pull/14840/files#diff-a602b2ba421d0da906b1d1915ca14c84b336da38e2ab907b695c441c5d58f5b3)
abstract class A()(implicit val x: Int = 3) | ||
trait B extends A | ||
|
||
abstract class C()(using y: Int = 9) | ||
class D extends C() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you extend the test case to one that also includes the syntactically inserted param lists, you will see that the current fix doesn't work. Test case:
abstract class A()(implicit val x: Int = 3)
class A1 extends A
class A2 extends A()
abstract class B()(using y: Int = 9)
class B1 extends B
class B2 extends B()
abstract class C(implicit val x: Int = 3)
class C1 extends C
class C2 extends C()
abstract class D(using y: Int = 9)
class D1 extends D
class D2 extends D()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably even extend it to:
abstract class A()(implicit val x: Int = 3)
class A1 extends A
class A2 extends A()
abstract class B()(using y: Int = 9)
class B1 extends B
class B2 extends B()
abstract class C(implicit val x: Int = 3)
class C1 extends C
class C2 extends C()
abstract class D(using y: Int = 9)
class D1 extends D
class D2 extends D()
abstract class E()(implicit val x: Int = 3, val y: Int = 4)
class E1 extends E
class E2 extends E()
abstract class F()(using y: Int = 9, x: Int = 8)
class F1 extends F
class F2 extends F()
abstract class G(implicit val x: Int = 3, val y: Int = 4)
class G1 extends G
class G2 extends G()
abstract class H(using y: Int = 9, x: Int = 8)
class H1 extends H
class H2 extends H()
if args == Nil | ||
&& !fn.isInstanceOf[Apply] | ||
&& app.tpe.isImplicitMethod | ||
&& fn.symbol.isConstructor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that we should rather add another condition that checks if meth
actually requires the empty argument list i.e.
&& !meth.tpe.widen.isNullaryMethod
Closes #22061