diff options
author | Jason Zaugg <jzaugg@gmail.com> | 2016-03-09 10:50:14 +1100 |
---|---|---|
committer | Jason Zaugg <jzaugg@gmail.com> | 2016-03-09 10:50:14 +1100 |
commit | c5f6b5c759378ad2fd90f77f4d0fb161c0266c45 (patch) | |
tree | f5893131c95f02b9457814420d97017e59e4672e | |
parent | a926b840e1e756c0dcd936499583ed19d357b97b (diff) | |
parent | d1def30417d44ef2a6830b3337bf4063c7144b4b (diff) | |
download | scala-c5f6b5c759378ad2fd90f77f4d0fb161c0266c45.tar.gz scala-c5f6b5c759378ad2fd90f77f4d0fb161c0266c45.tar.bz2 scala-c5f6b5c759378ad2fd90f77f4d0fb161c0266c45.zip |
Merge pull request #4970 from retronym/ticket/9658
SI-9658 Fix crosstalk between partial fun. and GADT match
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 | ||||
-rw-r--r-- | test/files/pos/t9658.scala | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 783db65b33..6676a0aeaf 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -2584,8 +2584,8 @@ trait Typers extends Adaptations with Tags with TypersTracking with PatternTyper // the default uses applyOrElse's first parameter since the scrut's type has been widened val match_ = { - val defaultCase = methodBodyTyper.typedCase( - mkDefaultCase(methodBodyTyper.typed1(REF(default) APPLY (REF(x)), mode, B1.tpe).setType(B1.tpe)), argTp, B1.tpe) + val cdef = mkDefaultCase(methodBodyTyper.typed1(REF(default) APPLY (REF(x)), mode, B1.tpe).setType(B1.tpe)) + val List(defaultCase) = methodBodyTyper.typedCases(List(cdef), argTp, B1.tpe) treeCopy.Match(match0, match0.selector, match0.cases :+ defaultCase) } match_ setType B1.tpe diff --git a/test/files/pos/t9658.scala b/test/files/pos/t9658.scala new file mode 100644 index 0000000000..a2c695a8ae --- /dev/null +++ b/test/files/pos/t9658.scala @@ -0,0 +1,10 @@ +sealed trait G[T] +case object GI extends G[Int] + +class C { + def typerFail[T](rt: G[T]): T = rt match { + case GI => + { case x => x } : PartialFunction[Any, Any] // comment this line, compiles. + 0 // found Int, required T + } +} |