-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #4582: use untpd.New in maybeCall #4827
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
Conversation
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
@@ -0,0 +1,2 @@ | |||
trait T[A: Numeric] | |||
class TX[A: Numeric] extends T[A] |
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.
This doesn't exercice the code you changed but I would add a test with an argument list. E.g.
trait T2[A: Numeric](x: Int)
class T2X[A: Numeric] extends T[A](1)
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've just added it.
@@ -1475,8 +1475,7 @@ class Typer extends Namer | |||
*/ | |||
def maybeCall(ref: Tree, psym: Symbol, cinfo: Type): Tree = cinfo.stripPoly match { | |||
case cinfo @ MethodType(Nil) if cinfo.resultType.isImplicitMethod => | |||
val icall = New(ref).select(nme.CONSTRUCTOR).appliedToNone | |||
typedExpr(untpd.TypedSplice(icall))(superCtx) | |||
typedExpr(untpd.New(ref, Nil))(superCtx) |
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 love when people fix bugs by removing code! ❤️
@Medowhill Could we also test the interaction with #4798? That is, try adding variants of those tests with context bounds. Hopefully that already just works! |
I think this issue is orthogonal to #4798 because #4798 is related to type aliases for classes rather than traits. For example, the following code is already compiled successfully at the master branch. trait A[X]
object O {
type T[X] = A[X]
class B[X] extends T[X]
}
However, adding a test can be meaningful. Do you think it would be better to add the following test? trait A[X: Numeric]
object O {
type T[X] = A[X]
class B[X: Numeric] extends T[X]
} |
Yep, I'm talking about adding tests — I only wondered because this code calls class A[X: Numeric]
type T[X, Y] = A[X]
type Foo[X, Y] = T[X, Y]
class B[X: Numeric] extends Foo[X, Int] |
I found a new issue while writing tests. trait T[X]
type Foo[X, Y] = T[X]
class D[X] extends Foo[X, Unit] trait T[X: Numeric]
type Foo[X] = T[X]
class D[X: Numeric] extends Foo[X] Two above examples were compiled. trait T[X: Numeric]
type Foo[X, Y] = T[X]
class D[X: Numeric] extends Foo[X, Unit] However, this one resulted the following crash: Exception in thread "main" java.lang.AssertionError: assertion failed: missing parameters for trait T from ($outer: C, implicit evidence$2: scala.math.Numeric) extends Object() with T {
private implicit val evidence$2: scala.math.Numeric
private val $outer: C
private <accessor> def $outer(): C = this.$outer
final def C$D$$$outer(): C = D.this.$outer()
} should have been caught in typer
at scala.Predef$.assert(Predef.scala:219)
at dotty.tools.dotc.transform.Mixin.nextArgument$1(Mixin.scala:209)
at dotty.tools.dotc.transform.Mixin.$anonfun$transformTemplate$12(Mixin.scala:235)
at scala.collection.TraversableLike$WithFilter.$anonfun$map$2(TraversableLike.scala:739)
at scala.collection.immutable.List.foreach(List.scala:389)
at scala.collection.TraversableLike$WithFilter.map(TraversableLike.scala:738)
at dotty.tools.dotc.transform.Mixin.traitInits$1(Mixin.scala:217)
at dotty.tools.dotc.transform.Mixin.$anonfun$transformTemplate$17(Mixin.scala:263)
at scala.collection.immutable.List.flatMap(List.scala:335)
at dotty.tools.dotc.transform.Mixin.transformTemplate(Mixin.scala:262)
at dotty.tools.dotc.transform.Mixin.transformTemplate(Mixin.scala:98)
at dotty.tools.dotc.transform.MegaPhase.goTemplate(MegaPhase.scala:922) |
Please open an issue |
I've just opened it: #4837. |
No description provided.