-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Crash when extending a type alias to a trait with implicit parameter #4837
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
Comments
Further investigation 1st code: // after frontend
class D[X >: Nothing <: Any]() extends Object() with C.this.Foo[D.this.X, Unit] {
// after erasure
class D($outer: C) extends Object() with T { 2nd code: // after frontend
class D[X >: Nothing <: Any](implicit evidence$2: Numeric[X])
extends Object() with T[D.this.X]()(evidence$2) {
// after erasure
class D($outer: C, implicit evidence$2: scala.math.Numeric) extends Object() with T(evidence$2) { 3rd code: // after frontend
class D[X >: Nothing <: Any](implicit evidence$2: Numeric[X])
extends Object () with C.this.Foo[D.this.X, Unit] {
// after erasure
class D($outer: C, implicit evidence$2: scala.math.Numeric) extends Object() with T { and another crash trait T(x: Int)
type Foo[X] = T
class D extends Foo[Int] It should be rejected by the typer but it passed the phase and resulted the same crash. |
I think changing diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala
index da66c5b62..c37d0d419 100644
--- a/compiler/src/dotty/tools/dotc/typer/Typer.scala
+++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala
@@ -1475,7 +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 =>
- typedExpr(untpd.New(ref, Nil))(superCtx)
+ typedExpr(untpd.New(untpd.TypedSplice(ref), Nil))(superCtx)
case cinfo @ MethodType(Nil) if !cinfo.resultType.isInstanceOf[MethodType] =>
ref
case cinfo: MethodType =>
@@ -1492,7 +1492,7 @@ class Typer extends Namer
def typedParent(tree: untpd.Tree): Tree = {
var result = if (tree.isType) typedType(tree)(superCtx) else typedExpr(tree)(superCtx)
- val psym = result.tpe.typeSymbol
+ val psym = result.tpe.dealias.typeSymbol
if (seenParents.contains(psym) && !cls.isRefinementClass)
ctx.error(i"$psym is extended twice", tree.pos)
seenParents += psym However, it needs a correct implementation of |
allanrenucci
added a commit
that referenced
this issue
Jul 30, 2018
Fix #4837: use dealiased type for parent symbol
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I found this issue while trying to write some tests for issue #4582. PR #4827 is related.
Two above examples were compiled.
However, this one resulted the following crash:
The text was updated successfully, but these errors were encountered: