Skip to content

Fix #2234: Dealias before type erasing #2236

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 3 commits into from
Apr 18, 2017
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: 4 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeErasure.scala
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
defn.FunctionType(0)
case AndType(tp1, tp2) =>
erasedGlb(this(tp1), this(tp2), isJava)
case tp: HKApply =>
apply(tp.superType)
case OrType(tp1, tp2) =>
ctx.typeComparer.orType(this(tp1), this(tp2), erased = true)
case tp: MethodType =>
Expand Down Expand Up @@ -508,6 +510,8 @@ class TypeErasure(isJava: Boolean, semiEraseVCs: Boolean, isConstructor: Boolean
normalizeClass(sym.asClass).fullName.asTypeName
case defn.ArrayOf(elem) =>
sigName(this(tp))
case tp: HKApply =>
sigName(tp.superType)
case JavaArrayType(elem) =>
sigName(elem) ++ "[]"
case tp: TermRef =>
Expand Down
13 changes: 13 additions & 0 deletions tests/pos/i2234.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
object Test {
type Dummy[A] = A

def a(d: Dummy[String]) = ()
def a(d: Dummy[Int]) = ()

implicit def dummy[A]: Dummy[A] = null.asInstanceOf[A]
def m(x: List[String])(implicit d: Dummy[String]) = "string"
def m(x: List[Int])(implicit d: Dummy[Int]) = "int"

m(List(1, 2, 3))
m(List("a"))
}