Skip to content

Fix #4837: use dealiased type for parent symbol #4838

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

Merged
merged 1 commit into from
Jul 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1501,7 +1501,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)(superCtx), Nil))(superCtx)
case cinfo @ MethodType(Nil) if !cinfo.resultType.isInstanceOf[MethodType] =>
ref
case cinfo: MethodType =>
Expand All @@ -1518,7 +1518,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
Expand Down
6 changes: 6 additions & 0 deletions tests/neg/i4837.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
trait T(x: Int)

class C {
type Foo[X] = T
class D extends Foo[Unit] // error
}
11 changes: 11 additions & 0 deletions tests/pos/i4837.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
trait T[X: Numeric]

class C {
type S[X] = T[X]
type Foo[X, Y] = T[X]
type Bar[X, Y] = Foo[X, Y]

class D[X: Numeric] extends S[X]
class E[X: Numeric] extends Foo[X, Unit]
class F[X: Numeric] extends Bar[X, Unit]
}