Skip to content

Commit 338b053

Browse files
committed
Merge pull request scala#3356 from retronym/ticket/8138
Fix bug with super-accessors / dependent types
2 parents b3ad753 + 1baf11a commit 338b053

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

src/compiler/scala/tools/nsc/transform/UnCurry.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,13 @@ abstract class UnCurry extends InfoTransform
878878
case Packed(param, tempVal) => (param, tempVal)
879879
}.unzip
880880

881-
val rhs1 = localTyper.typedPos(rhs.pos) {
882-
// Patch the method body to refer to the temp vals
883-
val rhsSubstituted = rhs.substituteSymbols(packedParams map (_.symbol), tempVals map (_.symbol))
884-
// The new method body: { val p$1 = p.asInstanceOf[<dependent type>]; ...; <rhsSubstituted> }
885-
Block(tempVals, rhsSubstituted)
881+
val rhs1 = if (tempVals.isEmpty) rhs else {
882+
localTyper.typedPos(rhs.pos) {
883+
// Patch the method body to refer to the temp vals
884+
val rhsSubstituted = rhs.substituteSymbols(packedParams map (_.symbol), tempVals map (_.symbol))
885+
// The new method body: { val p$1 = p.asInstanceOf[<dependent type>]; ...; <rhsSubstituted> }
886+
Block(tempVals, rhsSubstituted)
887+
}
886888
}
887889

888890
(allParams :: Nil, rhs1)

test/files/pos/t8138.scala

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
class U {
3+
trait Transformer {
4+
def transform(a: Tree): Tree = ???
5+
}
6+
trait Tree
7+
}
8+
9+
object Test {
10+
def m(u: U) = {
11+
class C extends u.Transformer {
12+
override def transform(t: u.Tree): u.Tree = {
13+
null match {
14+
case _ =>
15+
// crashes in GenICode:
16+
// error: Unknown type: <notype>, <notype> [class scala.reflect.internal.Types$NoType$, class scala.reflect.internal.Types$NoType$] TypeRef? false
17+
(y: Any) => super.transform(???)
18+
null
19+
}
20+
???
21+
}
22+
}
23+
}
24+
}

0 commit comments

Comments
 (0)